GoLand is a popular IDE for developing Go projects from JetBrains. If you’re a GoLand user, you can find useful tips and tricks for setting up your GoLand to develop Sourcegraph.
This page isn’t an exhaustive list of general-purpose tips for using GoLand; it aims to remain Sourcegraph specific.
Correct GOROOT, GOPATH, and Modules settings after running
GoLand automatically picks up the
.editorconfig file committed at the root of our repository. You don't need to do anything, just make sure that you don't disable the bundled plugin.
Configure your GoLand like this to respect our imports settings:
Fill paragraph for Go comments
Useful feature for making Go code comments look consistent across the codebase. We don't enforce the paragraph width at the moment, but we default to GoLand's default setting (80).
See it in action here: https://www.jetbrains.com/go/guide/tips/fill-paragraph-for-go-comments/
Use "code folding" to see previews of formatted strings
Wondering what string is logged here?
logger.Info(fmt.Sprintf("%s (sampling immunity token: %s)", record.Action, uuid.New().String()), fields...)
Enable code folding to see string previews:
- Editor -> General -> Code Folding -> check "Format strings" in "Go" section