How to install go language on mac

王林
Release: 2023-01-11 09:23:29
Original
4114 people have browsed it

How to install go language under mac: first download the corresponding version of the installation package from the go language official website; then double-click the installation package to start the installation. The installation package is installed in the [/usr/local] directory by default; finally, in the terminal Run the [go version] command to check whether the installation is successful.

How to install go language on mac

The operating environment of this article: mac os X system, GO 1.11.2, macbook pro computer.

(Learning video sharing: Programming video)

Specific method:

First download the installation package of the corresponding version from the Go language official website (https: //golang.google.cn/dl/)

The Go language development package for Mac OS is in .pkg format. Double-click the installation package we downloaded to start the installation.

How to install go language on mac

# Under Mac OS, it is a fool-proof installation. Just click "Continue" all the way and I won't go into details.

How to install go language on mac

The installation package will be installed in the /usr/local directory by default, as shown below.

How to install go language on mac

#After the installation is complete, run go version in the terminal. If information similar to the following is displayed, the installation is successful.

go version go1.13.4 darwin/amd64
Copy after login

Set the GOPATH environment variable

Before we start writing go project code, we need to configure the environment variables first. Edit ~/.bash_profile (just run vi ~/.bash_profile in the terminal) to add the following line of code (if you can’t find .bash_profile, just create one yourself)

export GOPATH=$HOME/go
Copy after login

Save and exit your editor. Then run the following command in the terminal

source ~/.bash_profile
Copy after login

Tip: $HOME is the user home directory under each computer. Each computer may be different. You can run echo $HOME in the terminal to get

GOROOT means that the installation directory of the Go development package is /usr/local/go by default. If not, it can be set in the bash_profile file.

export GOROOT=/usr/local/go
Copy after login

Then save and exit the editor, and run the source ~/.bash_profile command.

Related recommendations: golang tutorial

The above is the detailed content of How to install go language on mac. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!