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.
state.go
package main
import "fmt"
func printHello() {
fmt.Println("Hello World!")
}
main.go
package main
func main() {
printHello()
}
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
CodePudding user response:
With main.go
opened in the editor.
Click on the green arrow at the left side of main function.
It will run and creates a run configuration that you can customize.
CodePudding user response:
You don't have to run the state.go, just run main.go the IE will take care of it since they are in the same package(main).