如何将新文件添加到Go项目

I am using the Go plugin for IntelliJ Idea.

I'm not sure how I got my project working like this but I am able to run my Main.go file and it includes all my other files in the project that I can reference. That is perfect.

The problem now is that when I go and create a new "*.go" file it's not included in the IDE build and I get compiled errors wherever I refer to the contents of that file.

How can I fix this?

i think you can set GOPATH in the ~/.bash_profile, e.g. GOPATH=~/code/go export GOPATH

and source ~/.bash_profile or restart the terminal. it will go to effect;

then put *.go or go project related with the main.go under the GOPATH.

finally, main.go will find the *.go.

There are two types of run configurations for Go applications: - Go Single file -> which is the equivalent of go run file.go - Go Application -> which is the equivalent of go build file / package and run the binary

By the sound of it, you want to run a Go Application with Run kind set to package. There you'll need to type the full package name, for example: github.com/dlsniper/demo/cmd/democmd At the moment support for running multiple files / building a directory is not present (there are some issues opened for it)