简体   繁体   中英

In an Eng Compute cluster - “ cannot find GOROOT directory: /usr/lib/go”

I am trying to use GO in an engineering cluster. I have a private workspace, say /eng/name/go_proj/ ; how do I set the env var and the path to point to my workspace?

machine2045> pwd
/eng/name/go_proj/
 
machine2045> env | grep GOROOT
machine2045> which go
/usr/company_name/bin/go

machine2045> go env GOROOT
go: cannot find GOROOT directory: /usr/local/go

machine2045> go get -u github.com/go-delve/delve/cmd/dlv
go: cannot find GOROOT directory: /usr/local/go


I do not want to modify my .bashrc if possible since that is not recommended.

GOROOT (if not set manually via environment variable) defaults to /usr/local/go. (EDIT: Well, it defaults to the parent directory of where the binary was compiled, but in many cases the end user is not compiling, they are downloading a precompiled binary... The point is that you need to be aware that there is a default GOROOT that will need to be overridden if you're using a non-standard directory for your go binary / installation).

Think of this as the parent folder of the bin folder that houses the go binary. Go install instructions also encourage you to install to this location.

GOPATH specifies the root of your projects (to track sources and packages for imports, etc). Think of this as the parent folder of the src, bin, and pkg folders used in go projects.

GOROOT should not be your workspace. GOPATH should.

If you don't want to modify your.bashrc or move your go installation to /usr/local/go, you should export a GOROOT and GOPATH variable manually, maybe in a launchmyproject.sh file:

export GOROOT=/usr/company_name/ && export GOPATH=/eng/name/go_proj/ && cd /eng/name/go_proj/ && vim main.go

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