New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cmd/go: module-aware get x.go should not look up the host x.go #18533
Comments
The I suspect something might be attempting to canonicalize your argument and removing the In any case, it should probably have a better error message. /cc @rsc |
In the current model, go get foo (with no -u) means to install foo and any missing dependencies, but not update anything. So if you have foo already 'go get foo' and 'go install foo' are the same. In general, you can list .go files instead of a package name and the go command will pretend they make up a package and do what you ask for them, for example build it or tell you information: go get foo/bar/x.go means get all the dependencies needed by that file and then build and install the file. The install will fail since it doesn't know where to install it, but you didn't get that far. All of this may be rethought this year, so I'm not inclined to make tweaks right now. The best solution is to change your repo name not to end in ".go". That's just not the convention and it's not going to work. |
This is the second report about using go get to get a repo ending in .go.
The first was intentional, the second was not, and the overwhelming
concensus was neither use cases were a good idea.
My suggestion is the go tool should refuse to download any repo ending in
.go.
…On Sat, 7 Jan 2017, 06:15 Brad Fitzpatrick ***@***.***> wrote:
The go get command takes a package as its argument, not a filename.
I suspect something might be attempting to canonicalize your argument and
removing the .go suffix.
In any case, it should probably have a better error message.
/cc @rsc <https://github.com/rsc>
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#18533 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAAcAwbwXXJ_g17OdIeAprB5ub2B_cdeks5rPpK1gaJpZM4Lcf-g>
.
|
Then this is somewhat underdocumented. |
It's not documented because it's wrong. Go get works on packages, not files.
… On 7 Jan 2017, at 16:16, opennota ***@***.***> wrote:
@rsc
go get foo/bar/x.go means get all the dependencies needed by that file and then build and install the file.
Then this is somewhat underdocumented.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.
|
Then |
That was my suggestion.
…On Sat, 7 Jan 2017, 18:50 opennota ***@***.***> wrote:
@davecheney <https://github.com/davecheney>
It's not documented because it's wrong. Go get works on packages, not
files.
Then go get should not reject any repos based on their suffix and should
not attempt to trim that suffix.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#18533 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAAcA4zhADIOKIrw_sbHq-WdOyQQwQaZks5rP0O2gaJpZM4Lcf-g>
.
|
Would Is it documented anywhere that repos cannot end in In my opinion for the 1.9 release there should be a more verbose error message when downloading a package which ends on |
I'm thinking: checking in Is it a good approach or it's too aggressive to fail if any package name is "wrong"? |
And when you name .go source files in place of a package, the command is operating on the package defined by those source files. See also "go build x.go y.go z.go", "go test x.go", and so on. |
Will keep in mind for next cycle. |
Module-aware get should just reject .go files on the command line. That will clear this up. We'll leave legacy GOPATH get alone until we remove it. |
Needs fix as described in previous comment. |
I believe this is done
|
What version of Go are you using (
go version
)?go version go1.7.4 darwin/amd64
What operating system and processor architecture are you using (
go env
)?MacOS Sierra 10.12.1
What did you do?
I tried to get a script I wrote from my personal GitHub Profile using
go get github.com/kevingimbel/vhost.go
What did you expect to see?
I expected to get the source code from github.com/kevingimbel/vhost.go to download to
$GOPATH/src/github/kevingimbel/vhost.go
What did you see instead?
Instead github.com/kevingimbel/vhost.go and github.com/kevingimbel/vhost were downloaded to
$GOPATH/src/github/kevingimbel
. The second one is a shell script which should not be downloaded when I specify the "url"github.com/kevingimbel/vhost.go
.Is this intended behaviour? Should
go get
look for similar names to what you specify, let's say in case of a typo? I expected it to only download one of the two repository, namelyvhost.go
which I specified.My script itself is broken, too, because it searches for a package named
vhost
which does not exist. When I clone the repository with git to$GOPATH/src/github.com/kevingimbel
and try to run it I get the following error:When I rename the directory
vhost.go
tovhost
it works as expected.What would be the best naming convention if two repositories under the same account have the "same" or similar name? To "fix" this I would need to re-name
vhost.go
tovhost
and the shell script to something likevhost.sh
. This might be an edge case but it should be documented somewhere since it can affect other users, too.Might be related to #18484.
The text was updated successfully, but these errors were encountered: