During the development of the go project, the following problems occurred.
Error problem:
Idea running error:
After go bulild,
go run main.go starts and the error message is as follows:
# command-line-arguments
./main.go:16:14: undefined: Load
Compilation finished with exit code 2
Running the binary, it succeeds:
analyze:
In my project, there is a config.go at the same level as main. When go runs, there is a problem of go loading multiple files, so all .go files need to be included in the parameters, that is
go run *.go
This will also work, but it's not optimal.
the best solution:
The outermost layer only puts the main.go that starts, and creates a new directory for storing other .go files:
in this way, the startup is successful.