go mod Unresolved dependency

If you create a new Go modules project in the IDE, Go modules are already enabled. If you pulled your Go modules project from Github, you need to enable Go modules manually.

Enable Go in a project

  1. Open settings by pressing Ctrl+Alt+S and navigate to Go | Go.

  2. Select the Enable Go modules integration checkbox.

  3. Click OK.

    Enable Go in a project

来源:https://www.jetbrains.com/help/go/create-a-project-with-go-modules-integration.html#enable-go-modules-in-a-project