![](/img/trans.png)
[英]How do I SET the GOPATH environment variable on Ubuntu? What file must I edit?
[英]how do I SET the GOPATH environment variable in go 1.11 on Ubuntu? What file must I edit?
ubuntu@ubuntu:~/.work/src/github.hpe.com/hybridpoc/marketplace-terraform-tf-broker$ go run main.go
main.go:10:2: cannot find package "github.hpe.com/hybridpoc/marketplace-terraform-tf-broker/broker/github" in any of:
/home/ubuntu/go/src/github.hpe.com/hybridpoc/marketplace-terraform-tf-broker/broker/github (from $GOROOT)
/home/ubuntu/work/src/github.hpe.com/hybridpoc/marketplace-terraform-tf-broker/broker/github (from $GOPATH)
main.go:11:2: cannot find package "github.hpe.com/hybridpoc/marketplace-terraform-tf-broker/handlers" in any of:
/home/ubuntu/go/src/github.hpe.com/hybridpoc/marketplace-terraform-tf-broker/handlers (from $GOROOT)
/home/ubuntu/work/src/github.hpe.com/hybridpoc/marketplace-terraform-tf-broker/handlers (from $GOPATH)
这个问题似乎是关于设置环境变量,而不是关于 Go 编程语言。
因此,有很多答案。 例如这个 ask.ubuntu 问题。
最简单的实验方法是在命令前加上NAME=value
前缀,例如:
$ GOPATH=/some/path go <command>
或者,如果您想将其扩展到同一会话中的多个 shell 命令,请执行以下操作:
$ export GOPATH=/some/path
$ go <command>
一旦这些工作正常,将GOPATH
设置添加到您的~/.bashrc
文件,以便以后的会话无需export
即可找到它
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.