简体   繁体   中英

Go workspace issue: how to differ local packages from remote packages?

My gopath points to $HOME/go directory. And I have some personal packages that I don't want to share on github or anywhere else (yet). However when I try to update the remote packages with go get -u all I get:

# cd /home/go/src/marcio/somePackage; git pull --ff-only
fatal: No remote repository specified.  Please, specify either a URL or a
remote name from which new revisions should be fetched.
package code.google.com/p/go.tools/astutil
        ...
        long list of dependencies
        ...
        imports marcio/somePackage: exit status 1

This is very confusing. How do I tell go get to differ the packages I maintain from the packages used as dependencies? Why the go tool thinks everything has to be fetched from a remote source?


UPDATE:

It looks like Go work spaces impose you to mix dependencies with user maintained code. This looks precarious. Sometimes ones want to wipe unused trash packages and live with the risk of wiping the wrong folder or uncommitted stuff, and many other problems... is there any way to keep user maintained packages separated from remote fetched dependencies?

go get -u is designed to fetch updates via VCS. If you want to selectively update packages, you'll have to use a more specific identifier. You still have the ... wildcard to use too.

For example, this will try and update all packages from github.com:

go get -u github.com/...

In general though, I would avoid blindly updating everything, as it would make it harder to track when a dependency has broken something, since unrelated projects you're not currently working with will have their dependencies updated too.

Update answer:

While you can operate with multiple GOPATH 's (they're colon separated just like PATH ), don't do it; it will cause more problem than it helps with. Use a single GOPATH , and even better, use a single GOPATH per project. That way you can update dependencies without risk of affecting other projects. There's are some vendoring tools you can look into to help with this ( godep for example)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM