Home  >  Article  >  Backend Development  >  Let’s talk about mac golang installation method

Let’s talk about mac golang installation method

PHPz
PHPzOriginal
2023-03-29 09:24:10755browse

In this article, we will explore how to install Golang under Mac operating system.

Golang is a fast, efficient, and reliable programming language developed and maintained by Google. It is widely used in network development, system programming, cloud computing and other fields, and has the characteristics of simple syntax, portability, and strong concurrency.

For Mac users, installing Golang is very simple and only requires a few simple steps.

1. Download Golang

First we need to download the Golang installation package for Mac operating system from the Golang official website. The download link is: https://golang.org/dl/ .

In the download page, we need to select the corresponding installation package according to the current system version. If you are not sure about the current system version, you can click the "Apple" logo in the upper left corner of the screen to enter the "About This Mac" tab to view it.

After selecting the appropriate installation package, click the "Download" button to start downloading. After the download is completed, open the downloaded installation package to start installing Golang.

2. Install Golang

After opening the installation package, we will see a Golang installation wizard. Click the "Continue" and "Install" buttons in sequence to start installing Golang.

The installation process may take some time, depending on your computer configuration. During the installation process, you may be asked to enter your computer account password to grant administrator rights to the installer.

After the installation is completed, you will see an "Installation Successful" prompt box, click the "Close" button.

3. Set environment variables

After installing Golang, we need to set several environment variables so that Golang can work normally.

Open the Terminal application and enter the following command:

cd ~
touch .bash_profile
open -e .bash_profile

This will open a text editor window so you can edit the .bash_profile file.

In the .bash_profile file, add the following:

export GOPATH=$HOME/go
export PATH=$PATH:/usr/local/go/bin:$GOPATH/bin

Save the file and close the window.

4. Test installation

Now, we can test whether our Golang installation is successful.

Open the terminal application and enter the following command:

go version

If you see output similar to "go version go1.16.3 darwin/amd64", it means that Golang has been installed and configured correctly environment variables.

5. Install Golang related tools

Before using Golang for development, we may also need to install some related tools, such as:

  • GoModules: for Manage dependencies of Golang projects.
  • Delve: Tool for debugging Golang programs.

These tools can be installed by running the following command in the terminal:

go get github.com/lucas-clemente/quic-go

The above command will install a tool named "quic-go", which you can replace with your Other tools required.

Summary

In this article, we discussed the steps to install Golang under Mac operating system. Overall, this is a very simple process that only requires a few simple steps to complete.

Once the installation is completed, we can use Golang for development and use some convenient tools to improve our development efficiency.

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

Statement:
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
Previous article:How to install golang macNext article:How to install golang mac