brew install golang

WBOY
Release: 2023-05-22 14:55:37
Original
1881 people have browsed it

Under Mac OS system, it is very convenient to use brew (Homebrew) to install golang, which only requires a few simple steps.

Step 1: Install brew

If you have already installed brew, you can skip this step. If you have not installed brew, please follow the steps below:

  1. Open the terminal
  2. Enter the following command and press Enter:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Copy after login
  1. Wait for the installation to complete.

Step 2: Install golang

  1. Open the terminal
  2. Enter the following command and press Enter:
brew install go
Copy after login
  1. Wait for the installation to complete.
  2. Verify whether golang is installed successfully. Enter the following command in the terminal and press Enter:
go version
Copy after login

If you see the following output, it means you have successfully installed golang:

go version go1.x.x darwin/amd64
Copy after login

Step 3: Configure the environment Variables

  1. Open Terminal
  2. Enter the following command and press Enter:
vi ~/.bash_profile
Copy after login
  1. In the open file, add the following code:
export GOPATH=$HOME/go
export PATH=$PATH:/usr/local/go/bin:$GOPATH/bin
Copy after login

The above code sets the GOPATH to the go folder under your home directory and adds the path to the Go binary to your PATH environment variable.

  1. Press the ESC key, enter: wq to save and exit.
  2. Enter the following command in the terminal and press Enter to make the configuration file take effect:
source ~/.bash_profile
Copy after login

Now, you have successfully installed golang and can do it in the command line tool use.

Summary:

Using brew to install golang is one of the simplest and fastest methods under Mac OS systems. The installation steps are very simple, with only three steps, you can start writing code in golang. At the same time, when configuring environment variables, set GOPATH to the go folder in your home directory, so that all your Go projects can be placed in one place for easy management and maintenance.

The above is the detailed content of brew install golang. 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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!