How to install the go language environment on a Mac computer: 1. Open the terminal and enter the "brew install go" or "brew install golang" command. 2. Download the installation package from the official website and click on the pkg file to install.
The operating environment of this tutorial: macOS Big Sur system, GO 1.11.2, MacBook Pro computer.
MAC There are two ways to install go
One, install through brew
Enter brew install in the terminal go or brew install golang. Before installation, you can use brew info go to view version information
##~ brew info go
# by default ##Configure environment variables
1. Open the terminal and enter cd ~ to enter the user’s home directory;
2. Enter the ls -all command to check whether .bash_profile exists;
3. There is a way to open the file using vim .bash_profile;
4. Enter i to enter vim editing mode;
5. Enter the following code,
GOPATH: the root directory for daily development . GOBIN: It is the bin directory under GOPATH.
export GOPATH=/Users/lcore/dev/code/go
export GOBIN=$GOPATH/binexport
PATH=$PATH:$GOBIN
Enter vim .bash_profile to check whether the save is successful
Enter go env to check the configuration results, mine is as follows
The next step is to install beego
In the terminal, enter go get github.com/astaxie/beego
Install the bee tool go get github.com/beego/bee
After the installation is completed, Enter bee new project name in the terminal and press Enter.
Then start programming, Saonian.
Recommended learning:
Golang tutorialThe above is the detailed content of How to install go language environment on mac computer. For more information, please follow other related articles on the PHP Chinese website!