Home > Backend Development > Golang > golang installation mac

golang installation mac

PHPz
Release: 2023-05-16 11:30:38
Original
851 people have browsed it

Golang is a programming language with high performance and powerful functions. Its highlight is that it is simple, fast, reliable and relatively safe. Installing Golang on macOS can provide developers with a powerful toolbox to make programming more convenient.

This article will introduce the steps to install Golang on macOS, including preparing the environment, downloading and installing Golang, configuring environment variables, etc. let's start!

Preparing the environment

Before installing Golang, you need to confirm your macOS system version to ensure that it meets the requirements of Golang.
Golang supports the following macOS system versions:

  • OS X 10.8 Mountain Lion or higher
  • macOS 10.10 Yosemite or higher

Download and Install Golang

1. Open the Golang official website:

http://golang.org/dl/

2. Select the version you want to install, it is recommended to choose the latest version of. You can choose different download versions according to your Mac system version and download the corresponding compressed package.

3. After the download is complete, decompress the compressed package to the /usr/local directory or other directories where you are located, and rename the decompressed folder to the "go" directory.

sudo tar -C /usr/local -xzf go1.15.6.linux-amd64.tar.gz
mv go goroot

Configure environment variables

Next You need to configure environment variables to let the system know the installation path of Golang and which version of Golang to use.

1. Enter the following command in the terminal to open and edit the bash configuration file:

nano ~/.bash_profile

2. Add the following content in the bash configuration file:

export GOROOT=/usr/local/go
export PATH=$PATH:$GOROOT/bin

3. After completion, press ctrl o, save the changes, and then press ctrl x to exit. Then use the following command to make the file effective:

source ~/.bash_profile

Copy after login

Test installation

After the installation is completed, we can run the test program to check whether Golang is successfully installed. Open the terminal and enter the following command:

go version

If the Golang version information is output, it proves that the installation is successful.

Summary

These are the steps to install Golang on macOS. It should be noted that before installing Golang, you need to ensure that your Mac system meets the requirements of Golang. During the installation process, you need to make sure to add the Golang installation path to the system's environment variables so that the system will know which version of Golang to use. Finally, check whether Golang was successfully installed by running the test program.

Golang is a very powerful programming language, and installing it on macOS is also very simple. I hope this article can help you successfully install Golang on macOS and start your programming journey!

The above is the detailed content of golang installation mac. For more information, please follow other related articles on the PHP Chinese website!

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