乱世@小熊 2014-01-08 16:36 采纳率: 25%
浏览 2098

如何在 Ubuntu 上设置 GOPATH 环境变量? 我必须编辑什么文件?

I am trying to do a go get:

go get github.com/go-sql-driver/mysql

and it fails with the following error:

package github.com/go-sql-driver/mysql: cannot download, $GOPATH not set. For more details see: go help gopath

when I do a go env , a list of Go values is shown as below:

ubuntu@ip-xxx-x-xx-x:~$ go env
GOARCH="amd64"
GOBIN=""
GOCHAR="6"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH=""
GORACE=""
GOROOT="/usr/lib/go"
GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64"
CC="gcc"
GOGCCFLAGS="-g -O2 -fPIC -m64 -pthread"
CGO_ENABLED="1"

clearly the GOPATH is not set, how and where do I set it?

I see many threads that mention this error but none that provide an answer to my question, which file needs to be edited to provide a value for this path?

转载于:https://stackoverflow.com/questions/21001387/how-do-i-set-the-gopath-environment-variable-on-ubuntu-what-file-must-i-edit

  • 写回答

21条回答 默认 最新

  • ℡Wang Yan 2014-01-08 16:48
    关注
    export GOPATH=/path/desired/here
    

    There is no need to edit any file, we can just use the command above to directly edit the Go environment variables.

    评论

报告相同问题?

悬赏问题

  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程
  • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
  • ¥15 关于smbclient 库的使用