Prepend $GOPATH/bin to $PATH for generate functions

We have go projects which use protoc and oapi-codegen. After doing “go install” to get the tools for these in my $GOPATH, the next obvious/logical thing I want to do is click the amazing “play” button next to lines like:

//go:generate protoc 

//go:generate oapi-codegen

But this fails, because Goland can't find the executables, because the $GOPATH/bin aren't automatically prepended to the $PATH within the IDE.  ON macOS, it's rather annoying to have to modify PATH outside the IDE for this. So, if it's safe, would be great of Goland added $GOPATH/bin automatically, for both the play button and the terminals.  If it's not safe to do automatically, would settle for an opt-in feature, like in pycharm there are checkboxes for configuring whether or not to add current directory to PYTHONPATH. 

0
2 comments

Maybe this is already happening and the issue is that I didn't have protoc installed.  If so, can someone point to docs where it explains if this is already happening?

0

Hi Klemens Metalci ! Thank you for the question. I think you can try experimenting with adding this environment variable in GoLand's Run/DEbug configuration as in this screenshot -

 

Will this work?

0

Please sign in to leave a comment.