Error "can't load package: package my_prog: found packages my_prog and main"
Solution 1:
Yes, each package must be defined in its own directory.
The source structure is defined in How to Write Go Code.
A package is a component that you can use in more than one program, that you can publish, import, get from an URL, etc. So it makes sense for it to have its own directory as much as a program can have a directory.
Solution 2:
Also, if all you are trying to do is break up the main.go file into multiple files, then just name the other files "package main" as long as you only define the main function in one of those files, you are good to go.
Solution 3:
Make sure that your package is installed in your $GOPATH
directory or already inside your workspace/package.
For example: if your $GOPATH = "c:\go"
, make sure that the package inside C:\Go\src\pkgName