goenv is Go's version control version control tool.
For Homebrew
$ brew install goenv
For git goenv installation
$ git clone https://github.com/syndbg/goenv.git ~/.goenv
Describe the path in the configuration file. (Description in the shell you are using)
$ echo 'export GOENV_ROOT="$HOME/.goenv"' >> ~/.zshrc
$ echo 'export PATH="$GOENV_ROOT/bin:$PATH"' >> ~/.zshrc
$ echo 'eval "$(goenv init -)"' >> ~/.zshrc
$ source ~/.zshrc //Update changes
$ goenv -v
goenv 2.0.0beta11
If you can confirm the version, you are done.
Display a list of versions that can be installed with the following command
$ goenv install -l
1.2.2
1.3.0
1.3.1
〜
1.15rc2
1.15.1
1.15.2
Install any version.
$ goenv install 1.**.*
~/.zshrc
$ echo 'export PATH="$GOROOT/bin:$PATH"' >> ~/.zshrc
$ echo 'export PATH="$PATH:$GOPATH/bin"' >> ~/.zshrc
$ source ~/.zshrc
Set the installed version to global. Also, switching to a version.
$goenv global 1.**.*
$ go version
go version go1.**.* darwin/amd64
If you can confirm the version, you are done.
First, install the Go plugin.
Next, we will install useful tools. First, open the settings and search for go.use language server
to see if it is checked.
After checking, open the display of all commands with `shift + ⌘ + P```, type
Go: Install / Update Tools
, and then
gocode``` and ``
gocode- Select and install other than gomod``` (since the code completion function is performed by gopls). If you don't see gopls here, try typing gopls in the search tab.
After installation, add the following to settings.json.
settings.json
"go.useLanguageServer": true,
"[go]": {
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.organizeImports": true,
},
"editor.snippetSuggestions": "none"
},
"gopls": {
"hoverKind": "SynopsisDocumentation",
"usePlaceholders": true,
"linkTarget": "pkg.go.dev",
"staticcheck": false,
"completionDocumentation": true,
"completeUnimported": true,
"deepCompletion": true
},
"files.autoSave": "afterDelay"
that's all!
Recommended Posts