go config on mac

it is kinda painful to configure go and its tools on vscode on mac for the first time and second time (if you did not record what you did for the first time …).

here are steps

install golang using brew

brew install go

check the followi…


This content originally appeared on DEV Community and was authored by Jingtian Zhang

it is kinda painful to configure go and its tools on vscode on mac for the first time and second time (if you did not record what you did for the first time ...).

here are steps

  1. install golang using brew
brew install go

  1. check the following commands
go env      // check go env vars
which go    // check which go
brew info go  // very useful info here

till here everything should work fine, but I used oh-my-zsh (which is just based on zsh, so you just need to configure stuff on .zshrc file), so I configure my .zshrc file

cd 
nano ~/.zshrc
#GOROOT
export GOROOT=/opt/homebrew/Cellar/go/1.17.5/libexec

#GOPATH WORKSPACE
export GOPATH=$HOME/go

#GOROOT BIN
export PATH=$PATH:$GOROOT/bin

#GOPATH BIN
export PATH=$PATH:$GOPATH/bin

you see that GOROOT info can be found from the previous step brew info go, and do not forget to add libexec after it, so it will become whatever I show above.

till here I decide to download a golang project and enter vscode to edit some go files, but I notice there are missing go-tools to install, and somehow they keep reporting errors

  1. timeout error (I am in China, so I need to configure a proxy for that)
  2. not found error (go tools not found issue explained below), can also check here

you can fix it by

mkdir -p $GOPATH/src/golang.org/x/

and cd into this directory and :

git clone https://github.com/golang/tools.git

after this go tools can be successfully implemented, and then you can go back to vscode and follow the popup and click install or install all to install go tools, and they should be good


This content originally appeared on DEV Community and was authored by Jingtian Zhang


Print Share Comment Cite Upload Translate Updates
APA

Jingtian Zhang | Sciencx (2022-02-08T13:38:01+00:00) go config on mac. Retrieved from https://www.scien.cx/2022/02/08/go-config-on-mac/

MLA
" » go config on mac." Jingtian Zhang | Sciencx - Tuesday February 8, 2022, https://www.scien.cx/2022/02/08/go-config-on-mac/
HARVARD
Jingtian Zhang | Sciencx Tuesday February 8, 2022 » go config on mac., viewed ,<https://www.scien.cx/2022/02/08/go-config-on-mac/>
VANCOUVER
Jingtian Zhang | Sciencx - » go config on mac. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2022/02/08/go-config-on-mac/
CHICAGO
" » go config on mac." Jingtian Zhang | Sciencx - Accessed . https://www.scien.cx/2022/02/08/go-config-on-mac/
IEEE
" » go config on mac." Jingtian Zhang | Sciencx [Online]. Available: https://www.scien.cx/2022/02/08/go-config-on-mac/. [Accessed: ]
rf:citation
» go config on mac | Jingtian Zhang | Sciencx | https://www.scien.cx/2022/02/08/go-config-on-mac/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.