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 build Go language Development Environment under Linux system

2025-04-07 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)05/31 Report--

This article introduces the relevant knowledge of "how to build the Go language development environment under the Linux system". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Note: please use root users to install Go development environment under Linux.

Download the Go file package

To download the source code of Go language from Golang Chinese community, you can execute the following command under the Linux command line:

Wget https://www.golangtc.com/static/go/1.8.3/go1.8.3.linux-amd64.tar.gz

After downloading, extract the file:

Tar-zxvf go1.8.3.linux-amd64.tar.gz

Get a go directory, execute the following command, and move to the / usr/local/ directory:

Mv go/ / usr/local/Go configuration environment variables

Open the / etc/profile file using the vim editor:

Vim / etc/profile

Configure the Go locale variable by adding the following at the bottom:

# set go environmentGOROOT=/usr/local/goGOBIN=$GOROOT/binPATH=$PATH:$GOBIN/export GOROOT GOBIN PATH

The environment variable is configured in the code > / etc/profile file to ensure that this environment variable is available to every user on the machine. Execute the following command to make the environment variable take effect:

Source / etc/profile

Verify whether the environment variable is in effect. If the console outputs the path configured above, the configuration is successful:

Echo $GOROOT

Switch to the user who deploys the Go service. Of course, you can continue to configure the GOPATH environment variable under the root user:

Vim / .profile

Edit the following at the bottom:

Export GOPATH=/data/go

Then run the following command to make the environment variable take effect:

Source / .profile

Create a main.go file under the / data/go directory and write the following:

Package mainimport "fmt" func main () {fmt.Println ("Hello, World!") }

Run after saving:

Go run / data/go/main.goHello, the world!

The successful printing of the message means that the installation is successful!

This is the end of the introduction of "how to build the Go language development environment under the Linux system". Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

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

Development

Wechat

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

12
Report