Build go from source

参考文档

https://golang.org/doc/install/source
https://golang.org/doc/install/source#environment

准备

  • 使用go 1.4.3编译最新的go src
    https://storage.googleapis.com/golang/go1.4.3.linux-amd64.tar.gz
    解压到go1.4
  • 环境变量
export GOROOT=$(pwd)/go
export GOOS=linux
export GOARCH=amd64
export GOROOT_BOOTSTRAP=$(pwd)/go1.4
  • Clone source
$ git clone https://github.com/golang/go
  • 目录结构
$ tree -d -L 1
.
├── go
├── go1.4

编译

cd go/src
all.bash

测试

新文件 ./hello.go

package main

import "fmt"

func main() {
    fmt.Println("hello world!")
}
$ go/bin/go run hello.go
hello world!

你可能感兴趣的:(Build go from source)