Golang (a) [environmental structures]

Download and install the official guide Golang

http://docs.studygolang.com/doc/install

1.Windows

OS: Windows 10 x64 Professional Edition

Golang: go1.14.1.windows-amd64.msi

1. Download

Golang of Download

https://studygolang.com/dl

go1.14.1.windows-amd64.msi download link

https://dl.google.com/go/go1.14.1.windows-amd64.msi

Windows version of the go-1.14.1 download
Here Insert Picture Description

2. Install

Double-installed go1.14.1.windows-amd64.msi
Here Insert Picture Description

3. Environment Variables

After installation is complete configuration environment variable

This [computer] right click -> Properties -> Advanced System Settings -> Advanced -> Environment Variables -> System Variables -> New

Environment variable name Explanation Examples
GOROOT Golang 1.14.1 mounting position D:\Program Files\Go
Gofatः Golang coding directory ( containing src [source projects] / pkg [dependencies] / bin [executable] three directories directory ) D:\ProgramData\Workspace\Go
GOBIN Binary executable directory % GOPATH% \ bin
GO111MODULE on / auto / off on
GOPROXY Agent (in particular especially important after GO111MODULE configured on or auto) https://goproxy.io
Path Windows executable files directory, you need appends% GOROOT% \ bin;% GOPATH% \ bin;% GOBIN%; ;%GOROOT%\bin;%GOPATH%\bin;%GOBIN%;

Here Insert Picture Description
Here Insert Picture Description
Here Insert Picture Description
First delete user variables in the environment variable GOPATH set system environment variables (default go installation time) after
Here Insert Picture Description
Here Insert Picture Description
all the environment variables configured, must save OK

4. Test

1. Open the DOS command terminal
Win + R input cmd, carriage
Here Insert Picture Description
Here Insert Picture Description
2. Enter go env

go env

Consistent with the content item the following configuration and configuration environment variable is the emergence of OK!

Here Insert Picture Description

3. View version

go version

Here Insert Picture Description
4. Help

go help

Here Insert Picture Description

2.Linux

Here Insert Picture Description

1.CentOS

OS: Linux CentOS release 07/07/1908 (Core)

Golang: go1.14.1.linux-amd64.tar.gz

1. Download

1. Install wget download tool

yum -y install wget

Here Insert Picture Description
2. Go to the home directory of the user admin

cd /home/admin/

Here Insert Picture Description
3. Download-amd64.tar.gz go1.14.1.linux
go1.14.1.linux-amd64.tar.gz of Download

https://studygolang.com/dl/golang/go1.14.1.linux-amd64.tar.gz

Download Command

wget https://studygolang.com/dl/golang/go1.14.1.linux-amd64.tar.gz

Here Insert Picture Description

2. Extract

1. extracted to / usr / local / directory

tar -zxvf /home/admin/go1.14.1.linux-amd64.tar.gz -C /usr/local/

2. Go to the / usr / local / go down to see if there is a directory

cd /usr/local/
ls

Here Insert Picture Description

3. Environment Variables

1. Set working directory (pkg / bin / src three directories)

mkdir -p /home/admin/workspace/go/pkg /home/admin/workspace/go/bin /home/admin/workspace/go/src 

2. Install the vim

yum -y install vim

3. Set Environment Variables

vim /etc/profile

At the end of [uppercase keyboard press reaches the end of line G]
Here Insert Picture Description
is added the following:

export GOROOT=/usr/local/go
export GOPATH=/home/admin/workspace/go
export GOBIN=/home/admin/workspace/go/bin
export GO111MODULE="on"
export GOPROXY=https://goproxy.io
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin:$GOBIN:$GOPROXY

Here Insert Picture Description
Save and exit [esc ->: wq]

4. validate the configuration

source /etc/profile

Here Insert Picture Description

4. Test

1. Enter go env

go env

Consistent with the content item the following configuration and configuration environment variable is the emergence of OK! >
Here Insert Picture Description
2. Enter the go version View version

go version

Here Insert Picture Description

2.Ubuntu

OS: Ubuntu 18.04.4 LTS

Golang: go1.14.1.linux-amd64.tar.gz

1. Download

1. Install wget download tool

sudo apt-get install -y wget

Here Insert Picture Description
2. Go to the home directory of the user golang

cd /home/golang/

Here Insert Picture Description
3. Download-amd64.tar.gz go1.14.1.linux
go1.14.1.linux-amd64.tar.gz of Download

https://studygolang.com/dl/golang/go1.14.1.linux-amd64.tar.gz

Download Command

wget https://studygolang.com/dl/golang/go1.14.1.linux-amd64.tar.gz

2. Extract

1. extracted to / usr / local / directory

sudo tar -zxvf /home/golang/go1.14.1.linux-amd64.tar.gz -C /usr/local/

2. Go to the / usr / local / go down to see if there is a directory

cd /usr/local/
ls

Here Insert Picture Description

3. Environment Variables

1. Set working directory (pkg / bin / src three directories)

sudo mkdir -p /home/golang/workspace/go/pkg /home/golang/workspace/go/bin /home/golang/workspace/go/src 

2. Install the vim

sudo apt-get install -y vim

3. Set Environment Variables

sudo vim /etc/profile

At the end of [uppercase keyboard press reaches the end of line G]
Here Insert Picture Description
is added the following:

export GOROOT=/usr/local/go
export GOPATH=/home/golang/workspace/go
export GOBIN=/home/golang/workspace/go/bin
export GO111MODULE="on"
export GOPROXY=https://goproxy.io
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin:$GOBIN:$GOPROXY

Here Insert Picture Description
Save and exit [esc ->: wq]

4. validate the configuration

source /etc/profile

Here Insert Picture Description

4. Test

1. Enter go env

go env

Consistent with the content item the following configuration and configuration environment variable is the emergence of OK! >
Here Insert Picture Description
2. Enter the go version View version

go version

Here Insert Picture Description

3.macOS

macos download version golang

Next: golang (two) [the IDE configuration]

Published 25 original articles · won praise 11 · views 2801

Guess you like

Origin blog.csdn.net/weixin_42366378/article/details/104994847