Home Backend Development Golang Install golang under mac

Install golang under mac

May 14, 2023 pm 06:56 PM

With the continuous development and widespread application of Go language, more and more developers choose to use Go to build applications. If you are a Mac user and want to install the Go language on your computer, this article will provide you with some easy-to-understand steps and guidance to complete the installation easily.

Preparation before installation

Before installing Go, we need to make the following preparations:

  1. Download the Go installation package

Open the official website (https://golang.org/dl/) and select the latest version of the installation package under the macOS system to download. It is recommended to choose the installation package in compressed package (tar.gz) format and decompress it after downloading.

  1. Configuring environment variables

In macOS, we can use the Terminal to configure Go environment variables. Open a terminal and enter the following command in the command line:

nano ~/.bash_profile

Then add the following content to the opened file:

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

Save the file and exit.

  1. Check the installation

After completing the installation and configuring the environment variables, we need to check whether Go is installed normally. Enter the following command in the terminal:

go version

If the output is similar to the following, it means that Go has been successfully installed:

go version go1.17 darwin/amd64

Detailed explanation of the installation process

Next we will According to the above preparation steps, we will explain step by step how to install Go language on macOS system.

Step 1: Download the installation package

First, we need to open the official website (https://golang.org/dl/) and find the latest version of the installation under the macOS system on the page package to download. It is recommended to choose the installation package in compressed package (tar.gz) format, because the installation package in this format is relatively small and can save some download time and network traffic.

After the download is completed, we need to find the location of the downloaded file, and then double-click to open the compressed package. After decompression, we can see that the decompressed folder contains a go folder and some other files.

Step 2: Move the folder to the specified location

In order for Go to run normally, we need to move the unzipped folder to the specified location. Open the terminal and use the following command to enter the current user's home directory:

cd ~

Create a new folder in the home directory to store Go language-related files:

mkdir go

Then unzip Move the final folder to the folder you just created:

mv Downloads/go ~/go

Note: Downloads here is the download folder on my computer. If your download folder has a different name, please make the corresponding change based on the actual situation. Revise.

Step 3: Configure environment variables

In macOS, we need to configure environment variables to allow Go to run normally. Open a terminal and enter the following command in the command line:

nano ~/.bash_profile

Then add the following content to the opened file:

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

Save the file and exit.

Step 4: Check the installation

After completing the installation and configuring environment variables, we need to check whether Go is installed normally. Enter the following command in the terminal:

go version

If the output is similar to the following, Go has been successfully installed:

go version go1.17 darwin/amd64

Summary

Through the above steps, we can Easily install Go language on Mac system, and perform environment variable configuration and installation check.

Some points to note when installing Go:

  1. The downloaded installation package must match your system version.
  2. After decompression, place the folder in the specified location.
  3. Don’t forget to configure environment variables.
  4. After the installation is completed, you need to check whether the installation was successful.

I hope this article can provide useful help and guidance for Mac users when installing the Go language.

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

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

Hot AI Tools

Undress AI Tool

Undress AI Tool

Undress images for free

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How do I call a method on a struct instance in Go? How do I call a method on a struct instance in Go? Jun 24, 2025 pm 03:17 PM

In Go language, calling a structure method requires first defining the structure and the method that binds the receiver, and accessing it using a point number. After defining the structure Rectangle, the method can be declared through the value receiver or the pointer receiver; 1. Use the value receiver such as func(rRectangle)Area()int and directly call it through rect.Area(); 2. If you need to modify the structure, use the pointer receiver such as func(r*Rectangle)SetWidth(...), and Go will automatically handle the conversion of pointers and values; 3. When embedding the structure, the method of embedded structure will be improved, and it can be called directly through the outer structure; 4. Go does not need to force use getter/setter,

Strategies for Integrating Golang Services with Existing Python Infrastructure Strategies for Integrating Golang Services with Existing Python Infrastructure Jul 02, 2025 pm 04:39 PM

TointegrateGolangserviceswithexistingPythoninfrastructure,useRESTAPIsorgRPCforinter-servicecommunication,allowingGoandPythonappstointeractseamlesslythroughstandardizedprotocols.1.UseRESTAPIs(viaframeworkslikeGininGoandFlaskinPython)orgRPC(withProtoco

Understanding the Performance Differences Between Golang and Python for Web APIs Understanding the Performance Differences Between Golang and Python for Web APIs Jul 03, 2025 am 02:40 AM

Golangofferssuperiorperformance,nativeconcurrencyviagoroutines,andefficientresourceusage,makingitidealforhigh-traffic,low-latencyAPIs;2.Python,whileslowerduetointerpretationandtheGIL,provideseasierdevelopment,arichecosystem,andisbettersuitedforI/O-bo

Is golang frontend or backend Is golang frontend or backend Jul 08, 2025 am 01:44 AM

Golang is mainly used for back-end development, but it can also play an indirect role in the front-end field. Its design goals focus on high-performance, concurrent processing and system-level programming, and are suitable for building back-end applications such as API servers, microservices, distributed systems, database operations and CLI tools. Although Golang is not the mainstream language for web front-end, it can be compiled into JavaScript through GopherJS, run on WebAssembly through TinyGo, or generate HTML pages with a template engine to participate in front-end development. However, modern front-end development still needs to rely on JavaScript/TypeScript and its ecosystem. Therefore, Golang is more suitable for the technology stack selection with high-performance backend as the core.

How to completely and cleanly uninstall Golang from my system? How to completely and cleanly uninstall Golang from my system? Jun 30, 2025 am 01:58 AM

TocompletelyuninstallGolang,firstdeterminehowitwasinstalled(packagemanager,binary,source,etc.),thenremoveGobinariesanddirectories,cleanupenvironmentvariables,anddeleterelatedtoolsandcaches.Beginbycheckinginstallationmethod:commonmethodsincludepackage

How to use channels for communication between goroutines in golang? How to use channels for communication between goroutines in golang? Jun 26, 2025 pm 12:08 PM

In Go language, channel is used for communication and synchronization between goroutines. Declare the use of make function, such as ch:=make(chanstring), send the ch

How to use the select statement in golang for non-blocking channel operations and timeouts? How to use the select statement in golang for non-blocking channel operations and timeouts? Jun 26, 2025 pm 01:08 PM

In Go, using select statements can effectively handle non-blocking channel operations and implement timeout mechanisms. Non-blocking reception or sending operations are realized through the default branch, such as 1. Non-blocking reception: if there is a value, it will be received and printed, otherwise the default branch will be executed immediately; 2. Non-blocking transmission: If there is no receiver in the channel, the sending will be skipped. In addition, timeout control can be implemented in conjunction with time.After, such as waiting for the result or returning after 2 seconds. You can also combine non-blocking and timeout behaviors, try to get the value immediately, and wait for a short time after failure, so as to improve the program's concurrent response capabilities.

What does the 'cannot find package' error mean during go build? What does the 'cannot find package' error mean during go build? Jun 26, 2025 pm 12:57 PM

When encountering a "cannotfindpackage" error, it is usually because Go cannot find the target package or dependency. The solution is as follows: 1. Check whether the import path is correct and ensure that it is consistent with the module path or directory structure; 2. Confirm that the go.mod file has been initialized and use gomodinit and gomodtidy to manage dependencies; 3. Run goget to download missing dependencies or clean the module cache; 4. Make sure to execute commands in the correct directory context, or specify the complete module relative path for construction.

See all articles