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 run go program on Linux

2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

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

This article focuses on "how to run go programs on Linux". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to run go programs on Linux.

This article uses the tool centos7.3 virtual machine 1. Install GO

Open go's official website https://golang.org/dl/, and directly install the one selected in the click box. Right-click on the mouse and you will have an address. Save this address and download it using the wget instructions below.

Execute the instruction wget https://golang.org/dl/go1.14.4.linux-amd64.tar.gz to download

Extract go to / usr/local

Execute instruction tar-xzf go1.14.4.linux-amd64.tar.gz-C / usr/local/

After decompression, it will be directly in the go folder under / usr/local.

Until this step, our go is installed, and then we need to configure the environment variables.

Second, configure environment variables

GOROOT: this is the location where go is installed, and in this article is / usr/local/go GOPATH: this is the project directory

The configuration on Windows is like this. Next we need to configure the environment variable of go on linux, adding the following code to the file / etc/profile

Export GOROOT=/usr/local/go

Export GOPATH=/goLearn

Export PATH=$PATH:$GOROOT/bin

And execute source. / profile execute go version to see if go is installed successfully, which is shown in the following figure if the installation is successful. (if it is not consistent with the version downloaded by Kaka, it is the version number you downloaded.)

Execute the first GO program on Linux

This directory must be consistent with the set GOPATH, that is, the goLearn directory.

Create a src in this directory of golearn, and then store your own projects in this directory.

This case is just a simple implementation process, in order to demonstrate the execution of the GO program, later Kakha will always output some articles about go and then execute the program to check whether it can be executed successfully. There are many ways to execute go programs. Here we just use the go run instruction to demonstrate.

At this point, I believe you have a deeper understanding of "how to run go programs on Linux". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

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

Internet Technology

Wechat

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

12
Report