一、概述

golanglinuxwindowslinuxyum

二、步骤

1、下载安装包

https://golang.org/dl

linux安装Go1.9.2

windwosmaclinux源码
https://golangtc.com/download

linux安装Go1.9.2

2、解压

/usr/local/go
1
2
3
4
5
wget https://redirector.gvt1.com/edgedl/go/go1.9.2.linux-amd64.tar.gz
tar -zxvf go1.9.2.linux-amd64.tar.gz -C /usr/local
cd /usr/local/go/bin
./go version
go version go1.9.2 linux/amd64 ## 显示版本号
GOPATH/data/code/go
1
2
3
4
5
mkdir /data/code/go -p  
cd /data/code/go
mkdir src
mkdir bin
mkdir pkg

3、添加环境变量

/etc/profile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
[root@blog bin]# vi /etc/profile
//在最后一行加上,保存退出
export GOROOT=/usr/local/go
export GOPATH=/data/code/go
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin
[root@blog bin]# source /etc/profile //使环境变量配置生效
[root@blog bin]# go version
go version go1.9.2 linux/amd64
[root@blog go]# go env
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/data/code/go"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build274441176=/tmp/go-build"
CXX="g++"
CGO_ENABLED="1"
PKG_CONFIG="pkg-config"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
文件下载