When using IntelliJ IDEA with the Go plugin, or GoLand and using Go 1.11 or newer, you can enable Go modules by going to Preferences -> Languages & Frameworks -> Go -> Go Modules (vgo) and check the box 'Enable Go Modules (vgo) integration'.

When you have a project which was properly initialised by `go mod init`, and therefore has a `go.mod` and `go.sum` file, it will download the dependencies when building from command line with `go build` or from IntelliJ by pressing the green play icon.

However, the import statements to remote dependencies might still be red, even though they seem to have been downloaded and appear in the `go.mod` file.

Curiously enough, the go project will actually run from the command line, just not from within IntelliJ. Why is this and how can I fix this?