79413582

Date: 2025-02-05 03:34:03
Score: 1.5
Natty:
Report link

tl;dr: Follow this guide for your editor (has instructions for NeoVim, VSCode, Sublime Text, Helix Code): https://github.com/bazel-contrib/rules_go/wiki/Editor-setup

This solution does not require adding additional rules to your Bazel project. As long as you've loaded the @rules_go repository (which you presumably have to work with Go files), all you need to do is add a shell script somewhere for the language server to call into.

Notes

Also spent a lot of time digging around for this. It's annoying and surprisingly hard to find the solution! Thankfully it also annoyed other people: https://github.com/bazel-contrib/rules_go/issues/512

That Github solution explains that the Go tooling team has built up tooling for this a while ago. Basically any editor that uses the gopls language server can use this solution. The gopls editor is setup such that the binary it calls into for package resolution can be modified to point at a custom user script. The Go Bazel rules expose a target which will resolve Bazel built Go packages appropriately.

Sources

Reasons:
  • Blacklisted phrase (1): this guide
  • Blacklisted phrase (1): This link
  • Long answer (-1):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: Tenzin