簡體   English   中英

如何在 Ubuntu 上的 go 1.11 中設置 GOPATH 環境變量? 我必須編輯什么文件?

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM