Run go simple app with Jetbrains GoLand IDE


I've just started learning GO. Ok, I've some weird issue and did not figure out how to fix it. I have 2 go file. one is main.go and second is state.go and they are both in same package called main. In state.go file I defined simple function printHello, which then I'm calling it in main.go.


package main

import "fmt"

func printHello() {
    fmt.Println("Hello World!")


package main

func main()  {

When I run it in cmd with command: go run main.go state.go it works fine, but in GoLand IDE it didn't. I tried to build it changed Run Kind to Directory, but without success. Also attached image for more clarification


There are a few ways to manage your code dependencies: Go Modules & GOPATH (will be deprecated soon). I see your project directory doesn't contain go.mod file, so I suppose that you get started with GOPATH. If so, make sure that go env points GOPATH to your current project directory or use Go Modules instead.

I highly recommend starting with Go Modules and you can follow the steps:

  • Initialize go.mod file: go mod init projectName in the terminal (View | Tool Windows | Terminal).
  • Make sure Go modules integration is enabled under Preferences/Settings | Go | Go Modules.

After that, you should be able to run your code inside the IDE with Run kind | Package/Directory (Run | Edit Configurations).

Feel free to provide a bit more details after these steps if it doesn't help.


First step: I just crated Go.mod file
Actually I don't know, what it is  use for.

second step.

and this is gopath also



Please see for details about Go Modules.

Do you get the same error after these steps? What version of GoLand are you using?


yes, I got same error message. 
I'm using GoLand 2020.1 version


Could you please update GoLand to the latest available version, remove the configuration from Run | Edit Configurations and create a new one via the gutter icon over main() function?


Vuallla , it is working now as I created configuration via arrow button over main() function.

Thank you very much Daniil


Please sign in to leave a comment.