Skip to content
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: list template Context is missing GOPATH #14547

Closed
gima opened this issue Feb 28, 2016 · 13 comments
Closed

cmd/go: list template Context is missing GOPATH #14547

gima opened this issue Feb 28, 2016 · 13 comments
Milestone

Comments

@gima
Copy link

gima commented Feb 28, 2016

Please answer these questions before submitting your issue. Thanks!

  1. What version of Go are you using (go version)?

    go version go1.6 linux/amd64
    
  2. What operating system and processor architecture are you using (go env)?

    GOARCH="amd64"
    GOHOSTARCH="amd64"
    GOHOSTOS="linux"
    GOOS="linux"
    
  3. What did you do?

    go list -f '{{ context.GOPATH }}'

  4. What did you expect to see?

    Something along the lines of go env | grep GOPATH

  5. What did you see instead?

    Nothing was returned.

Investigation

I believe this to be the problem:

The Context struct for the template is constructed in context.go#L24 and assigned in list.go#L160, but the field GOPATH doesn't seem to be assigned.

I'm not knownledgeable enough to know if this has some meaning, but it seems like a bug.

@davecheney
Copy link
Contributor

Why not use go env GOPATH instead ?

On 28 Feb 2016, at 17:10, gima notifications@github.com wrote:

Please answer these questions before submitting your issue. Thanks!

What version of Go are you using (go version)?

go version go1.6 linux/amd64
What operating system and processor architecture are you using (go env)?

GOARCH="amd64"
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
What did you do?

go list -f '{{ context.GOPATH }}'

What did you expect to see?

Something along the lines of go env | grep GOPATH

What did you see instead?

Nothing was returned.

Investigation

I believe this to be the problem:

The Context struct for the template is constructed in context.go#L24 and assigned in list.go#L160, but the field GOPATH doesn't seem to be assigned.

I'm not knownledgeable enough to know if this has some meaning, but it seems like a bug.


Reply to this email directly or view it on GitHub.

@gima
Copy link
Author

gima commented Feb 28, 2016

I have two entries in GOPATH and was trying to see if fmt would give me only the first one, but then I hit this bug.

Already went ahead to wrote the desired GOPATH manually. (Trying to avoid platform-dependency like piping to sed or some such.)

@davecheney
Copy link
Contributor

Are you trying to determine which GOPATH entry the package was located in ?

On Sun, 28 Feb 2016, 17:51 gima, notifications@github.com wrote:

I have two entries in GOPATH and was trying to see if fmt would give me
only the first one, but then I hit this bug.

Already went ahead to wrote the desired GOPATH manually. (Trying to
avoid platform-dependency like piping to sed or some such.)


Reply to this email directly or view it on GitHub
#14547 (comment).

@gima
Copy link
Author

gima commented Feb 28, 2016

Not quite, but the end result is the same. I was abusing go fmt to try and obtain a single path from GOPATH, because using $GOPATH without parsing would not work if there were multiple paths in it

Specifically the first encountered path in GOPATH, because it's the path that go get downloads into.

@davecheney
Copy link
Contributor

When you say "single GOPATH" do you mean the first element in GOPATH ?

On 28 Feb 2016, at 18:24, gima notifications@github.com wrote:

Not quite. I was abusing go fmt to try and obtain a single path from GOPATH, because using $GOPATH without parsing would not work if there were multiple paths in it.


Reply to this email directly or view it on GitHub.

@gima
Copy link
Author

gima commented Feb 28, 2016

Yes, the first element of GOPATH.

@davecheney
Copy link
Contributor

If you need to do this in Go you can use
https://golang.org/pkg/path/filepath/#SplitList

If you need to do it in shell there are a few options depending on your
requirement.

On Sun, Feb 28, 2016 at 6:57 PM, gima notifications@github.com wrote:

Yes, the first element of GOPATH.


Reply to this email directly or view it on GitHub
#14547 (comment).

@gima
Copy link
Author

gima commented Feb 28, 2016

Thank you. I know these; I was just, uh.., doing something stupid, probably.
For what it's worth, here's the background: I wanted to install godoc to $GOPATH/bin/godoc instead of go get forcing it in to $GOROOT/bin/godoc.

And thus I worked around it:

go get -u -d golang.org/x/tools/cmd/godoc
go build -o $GOPATH/bin/godoc golang.org/x/tools/cmd/godoc

..I couldn't find what in-place-of $GOPATH would make the command the least platform-dependent (no grep, no sed, etc., as they wouldn't work in windows).

Really, this is not a big deal, I just reported this template context -problem as there seemed to be a bug in the code. I feel bad to have taken your time and to have bothered you for this long, apologies.

@davecheney
Copy link
Contributor

It's no problem. In the future consider asking questions like this in another forum.

@gima
Copy link
Author

gima commented Feb 28, 2016

beep The original bug still exists. And you promoted this into a question, not me >;) ..sorry..

@cespare
Copy link
Contributor

cespare commented Feb 28, 2016

Someone please reopen and change the title to something like

cmd/go: list template Context is missing GOPATH

I mailed CL 20010.

@gima FYI, the GOPATH that list will output will have all components listed, so it won't help with your problem.

@davecheney davecheney changed the title go fmt template's context initialized incompletely (GOPATH not assigned) cmd/go: list template Context is missing GOPATH Feb 28, 2016
@davecheney davecheney reopened this Feb 28, 2016
@gima
Copy link
Author

gima commented Feb 28, 2016

@cespare wrote:
@gima FYI, the GOPATH that list will output will have all components listed, so it won't help with your problem.

No problem. Just wanted to make sure that this issue got attention and possibly resolved.

@gopherbot
Copy link

CL https://golang.org/cl/20010 mentions this issue.

@ianlancetaylor ianlancetaylor added this to the Go1.7 milestone Feb 28, 2016
@golang golang locked and limited conversation to collaborators Mar 13, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants