Intellij golang build can't find dependencies in the same directory
When I do a build on the file with the main method Intellij can't find a file in the same package and same directory that contains a struct definition. The editor can find the struct definition because if i Ctrl-click on the struct name it goes to the definition. Why can't the build / run commands find it?
File: movietest.go
package main
import ("fmt")
func main() {
var movie Movie = Movie{1, "Test"}
fmt.Println(movie)
}
File: movies.go
package main
type Movie struct {
ID int `json:"id"`
Name string `json:"name"`
}
Please sign in to leave a comment.
This command works for me
Actually this will compile all go file and run your main function. So this works well
But also use go build and go install because using
go run *.gowill fail if you have *_test.go files (which you should have) and it will silently ignore// +buildconstraints which will either cause it to fail or behave in an unexpected way depending on how the build tags are used