Installation
git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.8.1
Add asdf
to zsh
ZSH & Homebrew
Add asdf.sh
to your ~/.zshrc
with:
echo -e "\n. $(brew --prefix asdf)/libexec/asdf.sh" >> ${ZDOTDIR:-~}/.zshrc
ZSH & Git
Add the following to ~/.zshrc
:
. $HOME/.asdf/asdf.sh
Install plugin dependencies
brew install gpg gawk
Install Golang
Version control config file: ~/.tool-versions
## Install golang plugin
asdf plugin-add golang
# Install global version golang
asdf install golang 1.17.7
# Setup global golang version
asdf global golang 1.17.7
# Setup local version of golang
asdf local golang 1.16
Setup Golang environment
Paste it into your .bashrc
or .zshrc
export GOPATH=$(go env GOPATH)
export GOROOT=$(go env GOROOT)
export GOBIN=$(go env GOBIN)
export PATH=$PATH:$GOPATH/bin
export PATH=$PATH:$GOROOT/bin
export PATH=$PATH:$GOBIN
# Source
# https://gist.github.com/vsouza/77e6b20520d07652ed7d#file-zshrc
Save and restart your terminal
Try to install something useful
# shfmt lint
go install mvdan.cc/sh/v3/cmd/shfmt@latest
# Git Semantic Versioning
go get -u github.com/linyows/git-semv/cmd/git-semv
References:
- https://gist.github.com/rubencaro/5ce32fb30bbfa70e7db6be14cf42a35c
- https://gist.github.com/rubencaro/5ce32fb30bbfa70e7db6be14cf42a35c
- https://stackoverflow.com/questions/25216765/gobin-not-set-cannot-run-go-install