简体   繁体   中英

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)

This question seems to be about setting environment variables, not about the Go programming language.

As such, there are many answers. For example this ask.ubuntu question .

The easiest way for experimentation is prefixing your commands with NAME=value , for example:

$ GOPATH=/some/path go <command>

Or, if you want to extend it to multiple shell commands within the same session, do:

$ export GOPATH=/some/path
$ go <command>

Once these work well, add the GOPATH setting to your ~/.bashrc file so that future sessions will find it without needing to export

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM