GoLand
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.
sg setup
Correct GOROOT, GOPATH, and Modules settings after running ![](https://storage.googleapis.com/sourcegraph-assets/docs/images/img/goland_gopath.png)
![](https://storage.googleapis.com/sourcegraph-assets/docs/images/img/goland_goroot.png)
![](https://storage.googleapis.com/sourcegraph-assets/docs/images/img/goland_modules.png)
Use .editorconfig
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.
![](https://storage.googleapis.com/sourcegraph-assets/docs/images/goland-editorconfig-plugin.png)
Imports style
Configure your GoLand like this to respect our imports settings:
![](https://storage.googleapis.com/sourcegraph-assets/docs/images/goland-imports.png)
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
![](https://storage.googleapis.com/sourcegraph-assets/docs/images/img/193618371-1b794c8d-3b41-472e-94b8-8f04a0c19e76.png)