Home  >  Article  >  Backend Development  >  macbook install golang

macbook install golang

王林
王林Original
2023-05-27 12:52:071174browse

MacBook is a very popular computer and is widely praised by users for its excellent performance. Golang is also a popular programming language at present. It has efficient compilation speed and concise syntax, so it is favored by developers. In this article, we will introduce how to install golang on MacBook.

Step 1: Download the installation package

First, we need to download the golang installation package from the official website. Open your favorite browser and enter the following URL:

https://golang.org/dl/

Select the version suitable for MacBook on the page, usually select the "MacOS" version . After the download is complete, open the downloaded installation package and follow the instructions to complete the installation.

Step 2: Configure environment variables

After the installation is completed, we need to configure the environment variables in the terminal so that we can use golang normally.

First, enter the following command in the terminal:

nano ~/.bash_profile

At this time, you will see an editor window, which is your bash configuration document. If nano is not installed on your MacBook, please install it yourself. In the editor, you need to add the following:

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

This tells the system to add the golang executable file path to PATH environment variable, so that you can directly call golang commands in the terminal.

When finished, you press "ctrl o" on your keyboard to save the file and "ctrl x" to exit the editor.

Step 3: Test

Now that you have completed the installation and configuration of golang, let's test whether the installation is successful.

Open the terminal and enter the following command:

go version

If you see output similar to the following, you have successfully installed and configured golang:

go version go1.13.1 darwin/amd64

At this point, the installation and configuration of golang on MacBook has been completed.

Summary:

In this article, we introduced how to install golang on MacBook. Go through the following steps:

  1. Download the installation package
  2. Configure environment variables
  3. Test

You have learned how to install on MacBook The complete process of installing golang. Hope this article helps you.

The above is the detailed content of macbook install golang. 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