前往:无法在symlink中打包

I have one go project. In this project, for example I have a lib_project that is a symlink to another directory, for example: github_project

After I pull source code to local, I update another git submodules (github_project is one submodule). And then I go here and compile project.

After that, I go to my main project and try to run command go. I meet exception:

package github.com/main_project/test.go: cannot find package "github.com/main_project/lib_project/some_random_file.go" in any of:

        /usr/local/Cellar/go/1.7.1/libexec/src/github.com/main_project/lib_project/some_random_file.go (from $GOROOT)

        /Users/my_user/Documents/go/src/github.com/main_project/lib_project/some_random_file.go (from $GOPATH)

I have tested and see that the directory github.com/main_project/lib_project/some_random_file.go is exsit. I can cd to this and open file. That looks like Go doesn't recognize symlink folder (in this case is lib_project)

The Go tools purposely don't follow symlinks. Make sure there aren't any in your GOPATH, and always use the full import path relative to $GOPATH/src/ for installed packages, and relative to the vendor/ directory for vendored packages.