mac installation golang environment

WBOY
Release: 2023-05-15 11:11:07
Original
1171 people have browsed it

As a developer, it is necessary to install the golang environment. On a mac, installing the golang environment is also very simple. This article will introduce how to install the golang environment on mac.

Install Xcode

Before installing golang, you need to install Xcode. Xcode is an integrated development environment (IDE) launched by Apple that can be used to develop macOS, iOS, watchOS, and tvOS application development tools.

If you have already installed Xcode, you can skip this step.

Search Xcode in the app store, download and install it. If you have already installed Xcode, it is recommended to update to the latest version.

Install Homebrew

Homebrew is a macOS package manager that can easily install and update software. Therefore, we can use Homebrew to install golang.

Enter the following command in the terminal to install Homebrew:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Copy after login

Install golang

Enter the following command in the terminal to install golang:

brew install go
Copy after login

At this time , golang has been installed. You can enter the following command in the terminal to check the installation of golang:

go version
Copy after login

Set environment variables

After completing the installation of golang, you need to set the environment variables. Enter the following command in the terminal:

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

The above command will create a golang workspace in the ~/go directory, and add the golang execution file path to the PATH variable.

If you want it to take effect permanently, you can add the above command to the ~/.bash_profile file.

Using goland

Installing goland is optional. goland is a golang integrated development environment (IDE) launched by JetBrains, which can improve development efficiency.

After downloading the goland DMG file, drag it to the Applications folder to complete the installation.

After opening goland, click "Create New Project", select "Go Module", and fill in your project name in the input box below the project name.

Click the create button and the project will be automatically initialized and opened in goland.

Conclusion

This article introduces how to install golang on mac and use it in goland. Hope this article can help you.

The above is the detailed content of mac installation golang environment. 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