Skip to main content
Version: go

安装

地址

Linux

1,设置 Go 环境变量

# 安装位置
export GOROOT=$HOME/go

# 调用
export PATH=$PATH:$GOROOT/bin

# 工作目录
export GOPATH=$HOME/Applications/Go

验证

source .bashrc

go env
env

2,安装 C 工具

 sudo apt-get install bison ed gawk gcc libc6-dev make

3, 获取 Go 源代码

地址

 wget https://storage.googleapis.com/golang/go<VERSION>.src.tar.gz
tar -zxvf go<VERSION>.src.tar.gz
sudo mv go $GOROOT

4, 构建 Go

 cd $GOROOT/src
./all.bash

5, 测试安装

hello_world.go

 package main

func main() {
println("Hello", "world")
}

go run hello_world.go

6,验证安装版本

 package main

import (
"fmt"
"runtime"
)

func main() {
fmt.Printf("%s", runtime.Version())
}

7, 版本

 - Go release:最新稳定版,实际开发最佳选择
- Go weekly:包含最近更新的版本,一般每周更新一次
- Go tip:永远保持最新的版本,相当于内测版