Skip to workspace topic: How to distinguish local packages from remote packages?

My gopat points to a directory $HOME/go

. And I have 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 communicate go get

to distinguish packages that I maintain from packages that are used as dependencies? Why does the go tool think everything should be retrieved from a remote source?


UPDATE:

It looks like Go workspaces impose you mixing dependencies with user maintained code. It looks unstable. Sometimes they want to wipe out unused garbage packages and live with the risk of wiping out the wrong folder or uncommitted stuff and many other problems ... is there a way to keep user-saved packages from removed selected dependencies?

+3


source to share


1 answer


go get -u

designed to receive updates via VCS. If you want to selectively update packages, you will have to use a more specific identifier. You still have the wildcard ...

.

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

go get -u github.com/...

      



In general, I would avoid blindly updating everything, as it would make it difficult to track when a dependency broke something, since unrelated projects that you are not currently working on will also update the dependencies.

Update answer:

As long as you can work with multiple GOPATH

(they are separated by a colon, like PATH

), don't do it; it will cause more problems than it helps. Use one GOPATH

, and even better, use one GOPATH

for each project. This way you can update dependencies without the risk of affecting other projects. There are some vendor tools you can help with ( godep )

+4


source







All Articles