기존에 설치된 go는 asdf와 충돌나니까 삭제
> sudo rm -rf ~/go 또는 /usr/.local/go
> which go로 어디 설치되어있는지 알 수 있음
export PATH="$HOME/.asdf/bin:$HOME/.asdf/shims:$PATH"
이거 zshrc나 bashrc에 추가
Install Go using asdf for Visual Studio Code on macOS
I had a lot of issues trying to install Golang on macOS using asdf package manager to develop on Visual Studio Code.
So here's the steps needed to setup it properly:
Open Terminal and install asdf with this command:
You have to install Homebrew before running the installation command.
brew install asdf
Don't forget to setup asdf on your shell by following asdf documentation.
After it finishes, it's time to install Go:
asdf install go 1.20.2
asdf global golang 1.20.2
asdf reshim golang 1.20.2
mkdir -p ~/go/{bin,pkg,src}
If you get an error message, remove the folder with this command:
sudo rm -rf ~/go
Re-run the command above to create package and source folders. Note: You have to run it as sudo because Go changes this folder permissions.
Add this line to your shell config file:
ZSH users: file is located at ~/.zshrc Bash users: file is located at ~/.zshrc
export GOROOT=~/.asdf/installs/golang/1.20.2/go
If you're using ZSH run this command on Terminal:
source ~/.zshrc
If you're using Bash run this command on Terminal:
source ~/.bashrc
Press Ctrl(Cmd) + Shift + P type User Settings bash and hit ENTER.
On this window paste the code down below and don't forget to Save:
"go.toolsGopath": "~/go/",
"go.gopath": "~/go/",
Open this URL and hit Install.
Press Ctrl(Cmd) + Shift + P type go install tools and hit ENTER. After you get a message like:
All tools successfully installed. You are ready to Go. :)
Reopen Visual Studio Code and everything should be working flawlessly.
'Development' 카테고리의 다른 글
localhost랑 127.0.0.1이랑 똑같은거 아니야? (0) | 2024.03.29 |
---|---|
postgresql sqlalchemy insert argument 32767개 사이즈 에러 (1) | 2024.03.28 |
Golang. miniredis를 사용하여 redis 테스트하기 (0) | 2024.03.12 |
windows 환경에서 zappa 설치 에러 해결법(UnicodeDecodeError) (0) | 2020.09.02 |