您的位置:首页 > 编程语言 > Go语言

mac配置go环境变量

2016-09-27 22:03 405 查看

1.从官网下载go的pkg安装包进行安装

2.打开终端输入
vi ~/.bash_profile
,系统如果没有的话会自动新建该文件(本人的没有…)

3. 写入以下内容

export GOROOT=/usr/local/go
export PATH=$PATH:$GOROOT/bin
export GOPATH=$HOME/yourpath


4.终端输入
source ~/.bash_profile


5.最后是测试,本人安装版本是
go1.6

终端输入:
go
,输出以下内容

Go is a tool for managing Go source code.

Usage:

go command [arguments]

The commands are:

build       compile packages and dependencies
clean       remove object files
doc         show documentation for package or symbol
env         print Go environment information
fix         run go tool fix on packages
fmt         run gofmt on package sources
generate    generate Go files by processing source
get         download and install packages and dependencies
install     compile and install packages and dependencies
list        list packages
run         compile and run Go program
test        test packages
tool        run specified go tool
version     print Go version
vet         run go tool vet on packages

Use "go help [command]" for more information about a command.

Additional help topics:

c           calling between Go and C
buildmode   description of build modes
filetype    file types
gopath      GOPATH environment variable
environment environment variables
importpath  import path syntax
packages    description of package lists
testflag    description of testing flags
testfunc    description of testing functions

Use "go help [topic]" for more information about that topic.


终端上输入
go env
,输出以下内容:

GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH=""
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GO15VENDOREXPERIMENT="1"
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fno-common"
CXX="clang++"
CGO_ENABLED="1"


6.GOPATH解释:GOPATH变量,Go从1.1版本开始必须设置这个变量,而且不能和Go的安装目录一样,这个目录用来存放Go源码,Go的可运行文件,以及相应的编译之后的包文件。

7.最后推荐一些学习go的书籍和项目

go源码

Go Web 编程

awesome-go

Go入门指南

Asta谢

beego

stathub-go

有问题或建议请联系
邮箱:981017952@qq.com,qq:981017952
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  go mac path 终端