Dev./Golang
[Golang] How to setup Go in mac
hotamul
2022. 11. 18. 00:20
Installation
❯ brew intstall go
When installed, run go version
to see the installed version of Go.
❯ go version
go version go1.17.6 darwin/arm64
Setup worksapce
The GOPATH
environment variable specifies the location of your workspace.
It defaults to a directory named go
inside your home directory.
❯ go env GOPATH
$HOME/go
add GOPATH
to your shell/bash/zsh initialization file .bash_profile
, .bashrc
or .zshrc
.
export GOPATH=$HOME/myproject/goworkspace
And add GOPATH/bin
directory to your PATH
environment to run Go programs anywhere.
export PATH=$PATH:$(go env GOPATH)/bin