转到,如何从github导入软件包并在不进行获取的情况下构建get

I need to import external package from github “github.com/xy/packageX” to MyProject/src/myProjcet.go. So I added import “github.com/xy/packageX” to myProject.go. If I run go build, I get:

myProject.go:9:2: import “github.com/xy/packageX”: cannot find package

So I have to run go get, and then go build.
Is there a way, how it can be built without using of go get? Or should I download it to MyProject/pkg and added this link to myProject.go? I am on Xubuntu 14.04.

If your project is up to the repository, such as github, When the initial "go install" will be "go get" even as packageX.

If you don't want to add your go project dependency to the global GOPATH, you can vendor it. (go 1.6+ recommended: see "Vendor Directories")

Go to the package which uses that import, and add it as a submodule in a vendor sub-folder.

cd GOPATH/src/myproject/mypackage
git submodule add -- https://github.com/<user>/<repo> vendor/github.com/<user>/<repo>
cd vendor/github.com/<user>/<repo>
go install
cd ../../../..
go install

Note: that repo might have itself other dependencies, that you would need to add in a similar fashion (in the same vendor folder)