当前位置:网站首页>02. Go language development environment configuration

02. Go language development environment configuration

2022-07-06 01:39:00 [email protected]

Catalog

1.  Go install

1.1  Linux Platform installation Go

1.1.1  Use Linux, You can quickly install in the following ways .

1.1.2  Set the environment variable

1.1.3  Check if the installation is successful

1.2  windows install go

1.2.1  download

 1.2.2  Add the installation path to the environment variable

 1.2.3  Check go stay windows Is the installation successful


1.  Go install

Go There are many ways to install , such as Go Source code installation 、Go Standard package installation 、 Third party tools (yumapt-get etc. ) install .
Take a look at two environment variables :
GOROOTGOROOT Namely Go Installation path for
GOPATHGOPATH It is used as the storage destination and import Search path at package time ( In fact, it's yours working directory
GOPATH Directory structure :
Need to put GOPATH The executable directory in is also configured into the environment variable , Otherwise, the third party you download by yourself go Tools will not work .
#####################################################

1.1  Linux Platform installation Go

go_code // ( example go_code by GOPATH Catalog )
-- bin // golang Compile executable file storage path , Can automatically generate .
-- pkg // golang Compilation of *.a Intermediate file storage path , Can automatically generate .
-- src // go Source path . according to golang Default Convention ,go run,go install The current working path of the command ( That is, on this road
Execute the above command directly ).
#####################################################

1.1.1  Use Linux, You can quickly install in the following ways .

$ wget https://golang.google.cn/dl/go1.18.3.linux-amd64.tar.gz 
$ tar -xzvf go1.18.3.linux-amd64.tar.gz
$ mv go /usr/local/

#####################################################

1.1.2  Set the environment variable

stay ~/.bashrc Add GOPATH Variable
#  The installation directory  
export GOROOT=/usr/local/go 
#  Code directory  
export GOPATH=~/code export 
PATH=$PATH:$GOPATH:$GOROOT/bin
After adding , perform  source ~/.bashrc
#####################################################

1.1.3  Check if the installation is successful

Input   go version see go Version number of

If appear go Version number of , shows go Installation successful

[[email protected] lianxi]# go version
go version go1.18.3 linux/amd64
[[email protected] lianxi]# 

#####################################################

1.2  windows install go

1.2.1  download

Download path https://golang.google.cn/dl/go1.18.3.windows-amd64.msi

Download it and install it directly .msi Just file

#####################################################

 1.2.2  Add the installation path to the environment variable

Example : I will go Installed in : E:\go

Enter the configuration of environment variables

Both user variables and environment variables can ,( Anyway, it's your own machine )

newly build GOROOT Variable , Variable value is go The installation path

  newly build GOPATH Variable , This variable is used to store go The path to the directory of the code (go_code It was built by myself )

  Then in the... Of the system variable path Add these two items to the variable

#####################################################

 1.2.3  Check go stay windows Is the installation successful

If the version number can be displayed successfully, the installation is successful

原网站

版权声明
本文为[[email protected]]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/187/202207060130187805.html