- GOROOT就是go的安装路径
在~/.bash_profile中添加下面语句:
GOROOT=/usr/local/go
export GOROOT
export $PATH:$GOROOT/bin;:
- GOPATH:
go installgo get
cd ~
mkdir gopath
GOPATH=/Users/username/gopath
go get
export $PATH:$GOPATH/bin
- 创建一个go项目, 并且编译运行:
mkdir goproject
cd goproject
touch hello.go
在hello.go中输入:
package main
import "fmt"
func main() {
fmt.Println("Hello, GO !")
}
go build./helloHello, GO !go run hello.go
source ~/.bash_profile