1024programmer Java Analysis of the process of building GO language development environment in Ubuntu18.04LTS-ubuntu

Analysis of the process of building GO language development environment in Ubuntu18.04LTS-ubuntu

1. Download the Go language installation package

Official website download address: https://golang.org/dl/, use the tar command to extract the archive package to the /usr/local directory:

sudo tar -C /usr/local -xzf go1.11.5.linux-amd64.tar.gz

2. Add environment variables and work variables to the system environment

First enter the profile file directory:

cd /etc

Open profile file:

sudo gedit profile

Add the following command line to the end of the file: (The first is the go installation package path, the second is your development space, the two need to be in different directories, otherwise the folders will be confused)

#GOexport PATH=$PATH:/usr/local/go/bin#GOPATHexport GOPATH=Your go workspace directory export PATH=$PATH:$GOPATH/bin

For all users, restart the computer to take effect; for the current user, use the source command in the terminal to load this $HOME/.profile to take effect.

source ~/.profile

3. Check the current go version

Any command line terminal:

go version

If the output is similar to the following, it means that your go installation environment and working environment are both configured successfully!

4. Test whether the installation is successful

Although the previous step has proven that go installation is successful, it is still in line with our practice of learning a new language by outputting a hello world.

Create the file hello.go in any directory you wish

Open the file and enter:

package mainimport “fmt”func main() { fmt.Printf(“hello, world\n”)}

Then run:

go run hello.go

Outputting the following results shows that you can start the exciting journey of GO language upgrade!

Reference documentation: http://docscn.studygolang.com/doc/install

This article is from the internet and does not represent1024programmerPosition, please indicate the source when reprinting:https://www.1024programmer.com/746492

author: admin

Previous article
Next article

Leave a Reply

Your email address will not be published. Required fields are marked *

Contact Us

Contact us

181-3619-1160

Online consultation: QQ交谈

E-mail: [email protected]

Working hours: Monday to Friday, 9:00-17:30, holidays off

Follow wechat
Scan wechat and follow us

Scan wechat and follow us

Follow Weibo
Back to top
首页
微信
电话
搜索