GOLANG配置

根据操作系统下载对应的软件包

https://golang.google.cn/dl/

GOROOT就是go的安装路径

vim /etc/profile,在末尾加上三行

```

export GOROOT=/usr/local/go
export GOPATH=/home/go
export PATH=$PATH:$GOROOT

```

在~/.bashrc中添加下面语句:

export GOROOT=/usr/local/go
export GOPATH=/Users/workspaces
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin

如果要上述设置生效, 可以执行命令: source ~/.bashrc

在hello.go中输入:

package main

import "fmt"

func main() {

      fmt.Println("Hello, GO !")

}

  • export GOROOT=/usr/local/go
  • export GOPATH=/home/go
  • export PATH=$PATH:$GOROOT
原文地址:https://www.cnblogs.com/enumx/p/12297667.html