Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to configure golang development environment in macOS

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

In this issue, the editor will bring you about how to configure the golang development environment in macOS. The article is rich in content and analyzes and narrates it from a professional point of view. I hope you can get something after reading this article.

First, install Homebrew

Open the terminal and enter the following command to install Homebrew

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

2. Install and configure golang

1. Install golang through brew

Enter the following command in the terminal to install golang

Brew install go

Or

Brew install golang

two。 Install golang by downloading the installation package

Download the golang software installation package from the official website Downloads.

3. Configure goproxy proxy

For well-known reasons, downloading golang-related modules is very difficult.

Here is a relatively reliable solution: go mod + goproxy

Open .bashrc or .zshrc through the editor, paste the following configuration to the end of the file, and save it.

# Enable the go modules featureexport GO111MODULE=on# Set the GOPROXY environment variableexport GOPROXY= https://mirrors.aliyun.com/goproxy/

Open the terminal and enter the following command to make the environment variable effective.

Source .bashrc

Or

Source .zshrc

Create a HelloWorld project and verify golang

Enter the following command at the terminal to create the HelloWorld project. If the compilation runs successfully, "Hello, World!" will be printed.

# create helloworld project mkdir helloworld#, enter helloworldcd helloworld#, create main.go file cat > main.go

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report