Links:
- Go Getting Start
- Tutorial
- W3 Schools
- Example
- geeksforgeeks
- GoLangPrograms
- Compile and Install
- DigitalOcean Tutorial
- Build and Install Go
Steps:
- Install go: https://go.dev/doc/install
Write some code
Create a directory:
mkcd hello
Initialize:
go mod init example/hello
Createa file: hello.go
code hello.go
Add code:
package main import "fmt" func main() { fmt.Println("Hello, World!") }
Run Code:
go run .
Call code in an external package
Install Module (like Pip in Python):
go get rsc.io/quote
After importing module add this to code:
package main import "fmt" import "rsc.io/quote" func main() { fmt.Println(quote.Go()) }
Add new module requirements and sums.
go mod tody
Run
go run .
Build
go build .
Execute
./hello