dominikh / go-mode.el

Emacs mode for the Go programming language
BSD 3-Clause "New" or "Revised" License
1.37k stars 209 forks source link

Get environment variables from `go env` to get default values #345

Closed kyepskee closed 4 years ago

kyepskee commented 4 years ago

I left $GOROOT unset in my .profile file, because I wanted to leave it at a default, which is also mirrored by go env's outputting the default $GOROOT value - /usr/lib/go/. However, in its current state go-guru.el doesn't check for defaults. For that reason I couldn't by default get the definition of http.Dir (from the standard library net/http), until I added: (setenv "GOROOT" "/usr/lib/go/").

The solution is obvious: if in the Emacs env, the value doesn't exist, get it from go env. It seems pretty simple, but I don't know Emacs Lisp well enough to submit a pull request, so I hope someone experienced can fix this one :)

psanford commented 4 years ago

It sounds like you are running into this issue: https://github.com/golang/go/issues/22418#issuecomment-338997709. If you rebuild guru on this system does that fix your issue?

Have you tried using gopls instead of guru? Guru isn't being actively worked on by the go team anymore but gopls has engineers on the go team that work on it full time. Here are some setup instructions for emacs: https://github.com/golang/tools/blob/master/gopls/doc/emacs.md