Installation
download Go itself for windows and install, confirm with go version
after.
|
|
For linux: https://go.dev/doc/install
|
|
Configuration
Use “go help doc” for more information about doc command
|
|
json package, Decoder object within json package, and Decode method on that Decoder object.
IDE
Install vscode using choco and confirmed with choco list -l
|
|
After installing golang.go extension. Got a prompt to install the gopls and go-ouitline.
|
|
Now, try creat a hello world program and try to features of those tool
- type pack to see it suggests package main
- type func to see it suggests func main{}
- type fmt.Println(“Hello world!") slowly to see it suggests the rest.
- save this file to see it added import “fmt”
- start a terminal and use go run . to see it runs properly.
Suggest to install go code --install-extension formulahendry.code-runner
, this way you can run go file with an shortcut.
GOPATH
This is where the packages live, weather download with go get command or created by your self.
Since Go 1.11, you don’t have to use GOPATH anymore. Simply go to your project directory and do this once:
|
|
For older version of Go, you need to set and export it. To be compatible with old packages, it’s BEST to set it.
|
|
After the $GOPATH in place, you can go get another package online, like the command example above.