golang-101-hacks(1)-create a development environment

golang-101-hacks(1)-create a development environment

Note: This article is a Chinese translation of golang-101-hacks . The original address of this article is very easy to create a Go development environment. Taking the Linux system as an example, you only need to download and your system from https://golang.org/dl/ Match the binary package, then unzip the package file and it will be OK. (Note that the downloaded package file version of the author's original text is a bit old. It is recommended to download the latest version. The latest version is currently 1.12)

# wget https://storage.googleapis.com/golang/go1.6.2.linux-amd64.tar.gz
# tar -C/usr/local/-xzf go1.6.2.linux-amd64.tar.gz

Return and put the decompressed package file in the/usr/local directory, and the installation is complete, but there are still some finishing work to be done: 1 In order to run the Go tool commands (go, gofmt) directly, you need to /usr/local/goset it to $PATH Environment variables

# cat/etc/profile  
......
PATH=$PATH:/usr/local/go/bin
export PATH 
......

2 The wall crack suggests that the installation directory of go is/usr/local/go in linux and c:\Go in window, because the path address is the default installation path address of the release version of go, otherwise you need to modify the environment variable $GOROOT .

# cat/etc/profile  
......
GOROOT=/path/to/go
export GOROOT

Therefore, the value of the environment variable $GOROOT needs to be modified only if go is not in the default path.

Reference: https://cloud.tencent.com/developer/article/1438453 golang-101-hacks(1)-Create a development environment-Cloud + Community-Tencent Cloud