Go installation and configuration in macOS environment

Go installation and configuration in macOS environment

1. Download the installation package

Try to choose the official website to download, and choose the required package according to your own system version and number of digits

insert image description here

2. Configure environment variables

After the installation is complete, we need to manually configure the environment variables

Open the terminal and enter cd ~ to enter the user's home directory;

Enter the ls -all command to see if .bash_profile exists;
insert image description here

vim .bash_profileOpen the file with if it exists ;

Enter i to enter vim editing mode;

Enter the following code:

export GOPATH=/Users/lcore/dev/code/go
export GOBIN=$GOPATH/binexport 
PATH=$PATH:$GOBIN

Save and exit with source ~/.bash_profilethe command to make the configuration take effect

Enter in the terminal go version, if the following figure appears, the installation is successful

insert image description here

Guess you like

Origin blog.csdn.net/a6661314/article/details/125649406