Hi everyone,
I never bothered too much with the details of "go get" until the issue
recently came up in a conversation with another developer who was also
annoyed by the clumsiness of the go tool in practice. I often work with
programs that are not in a GOPATH, but import some non-local packages. I
find the behavior a bit strange. Before opening a bug I wanted to ask here
if someone can shed some light on why things are the way they are.
In the following I'll assume that the directory $X contains the source of a
package ("main" in my case) which resides outside the GOPATH, but imports
some go get-able packages (like "golang.org/x/net/websocket"). If the $X is
the current directory it may be omitted when using go get. I may be
mistaken, but the options at the moment are pretty much this:
go get $X:
-Downloads missing dependencies
-Does not update sources of dependencies
-Executes go install $X
This is what I used to use ("go get; go build -i -o out && ./out"). This
actually works fine. But it will return 1 (error), due to "go install $X"
failing.
go get -d &X:
-Downloads missing dependencies
-Does not update source of dependency
I guess this is what I should have used instead of "go get". Instal
go get -u $X:
-Downloads missing dependencies
-Updates sources of existing dependencies
-Executes go install $X
This works great inside a GOPATH, but outside it is utterly useless when
used on a package outside the GOPATH, since it fails immediately with
"unrecognized import path ...". "go get -u -d" has the same problem.
So that leaves me wondering. How do I update the dependencies of a program
whose code resides outside of a GOPATH? "go get -u ..." runs way to long if
you have a lot of stuff in GOPATH.
Did I misunderstand something? Does anyone have a solution for this? If
not, here are three proposals in order of preference (not mutually
exclusive):
1. Change go get $X: Skip the "go install $X" if $X is outside the GOPATH
and just install the dependencies.
2. Change go get -u $X: Just skip the "unrecognized import path" issue and
continue updating the dependencies (I feel like this should make "go get -u
-d $X" work for me).
3. Don't change "go get" at all, but add the -u flag to "go build". Then
"go get -d && go build -u -i" would work great.
I know that none of these exactly fit the original idea of the "get" or
"build" command perfectly, but this is a real world problem in need of a
solution.
tldr: Please let me update dependencies of packages that are in arbitrary
directories.
Best regards,
Florian
--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.