Home > Article > Backend Development > brew install golang
Under Mac OS system, it is very convenient to use brew (Homebrew) to install golang, which only requires a few simple steps.
If you have already installed brew, you can skip this step. If you have not installed brew, please follow the steps below:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew install go
go version
If you see the following output, it means you have successfully installed golang:
go version go1.x.x darwin/amd64
vi ~/.bash_profile
export GOPATH=$HOME/go export PATH=$PATH:/usr/local/go/bin:$GOPATH/bin
The above code sets the GOPATH to the go folder under your home directory and adds the path to the Go binary to your PATH environment variable.
source ~/.bash_profile
Now, you have successfully installed golang and can do it in the command line tool use.
Summary:
Using brew to install golang is one of the simplest and fastest methods under Mac OS systems. The installation steps are very simple, with only three steps, you can start writing code in golang. At the same time, when configuring environment variables, set GOPATH to the go folder in your home directory, so that all your Go projects can be placed in one place for easy management and maintenance.
The above is the detailed content of brew install golang. For more information, please follow other related articles on the PHP Chinese website!