Closed shotexa closed 1 year ago
Thanks for your question.
GOPATH
is a go thing, and gobrew
can be isolated from this responsibility.
It is not possible for gobrew
to manage that path, as you can set it up using env var in your ~/.bashrc
.
My GOPATH
is set to the default default one by go
╰─$ go env|grep -i gopath
GOPATH="/Users/pulkit.kathuria/go"
╰─$ which gopls
/Users/pulkit.kathuria/go/bin/gopls
Actually you can set GOROOT
and GOPATH
by yourself as envs and gobrew
doesn't need to know about it.
I think @juev can articulate it better than me on this.
Hello!
You don’t need to set GOROOT, really, but for gobrew is it main point.
How to Write Go Code (with GOPATH) describes what the GOPATH variable is used for and what default values are used. It defaults to a directory named go inside your home directory, so $HOME/go on Unix, $home/go on Plan 9, and %USERPROFILE%\go (usually C:\Users\YourName\go) on Windows.
If you want, you can change this value to different location.
Hello, I'm new to go so please excuse me if it is a noob question.
I've installed go via
gobrew
, I like it for its simplicity over other go version managers. When I'm trying to usevsCode
, it asks me to installgopls
(go language server) for it to run via the commandgo install golang.org/x/tools/gopls@latest
, which has installed it in$HOME/go
and the binary is located in$HOME/go/bin/gopls
which is not on the$PATH
. According to go install manual (go help install
):Since
$GOPATH
is not defined, it has installed the executable in$HOME/go/bin
. I think go version manager should manage this aspect as well. Is this something that is planned? and where would you suggest pointing $GOPATH?