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

x/tools/go/packages: leading newline in error message #32363

Closed
dominikh opened this issue May 31, 2019 · 6 comments
Closed

x/tools/go/packages: leading newline in error message #32363

dominikh opened this issue May 31, 2019 · 6 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@dominikh
Copy link
Member

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

$ go version
go version go1.12.5 linux/amd64
go version devel +2165452a37 Fri May 31 11:26:23 2019 +0000 linux/amd64

What did you do?

https://play.golang.org/p/Ze4miT_P7Dn

What did you expect to see?

No leading newline in packages.Error.Msg

/cc @matloob

@gopherbot gopherbot added this to the Unreleased milestone May 31, 2019
@dominikh dominikh added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label May 31, 2019
@dominikh
Copy link
Member Author

Output of go list:

$ go list -json sandbox/foo
can't load package: package sandbox/foo: 
../foo/foo.go:1:1: expected 'package', found pckage

@matloob
Copy link
Contributor

matloob commented Jun 19, 2019

Is this what you're seeing? I don't see a leading newline in the message. I wonder if the issue has been fixed in a different cl?

<nil>
packages.Error{Pos:"", Msg:"cannot find package \"sandbox/foo\" in any of:\n\t/usr/local/go/src/sandbox/foo (from $GOROOT)\n\t/Users/matloob/go/src/sandbox/foo (from $GOPATH)", Kind:0}

@dominikh
Copy link
Member Author

I am seeing

<nil>
packages.Error{Pos:"", Msg:"\n/home/dominikh/prj/src/sandbox/foo/foo.go:1:1: expected 'package', found pckage", Kind:0}

You didn't create the appropriate sandbox/foo package and are getting a different error. Not all errors suffer from the leading newline problem.

I should've been clearer in my original report.

@matloob
Copy link
Contributor

matloob commented Jun 20, 2019

Oh sorry about that, thanks for pointing that out. I can reproduce. I'll try to get a fix out very soon

@matloob
Copy link
Contributor

matloob commented Jun 20, 2019

So this is a problem that originates in go list:

matloob$ GO111MODULE=off go list -e -json sandbox/foo
{
	"Dir": "/Users/matloob/go/src/sandbox/foo",
	"ImportPath": "sandbox/foo",
	"Root": "/Users/matloob/go",
	"Match": [
		"sandbox/foo"
	],
	"Incomplete": true,
	"Error": {
		"ImportStack": [
			"sandbox/foo"
		],
		"Pos": "",
		"Err": "\n../go/src/sandbox/foo/g.go:1:1: expected 'package', found pckage"
	}
}

Now I'm wondering if we should trim all the errors returned by go list...

@gopherbot
Copy link

Change https://golang.org/cl/183258 mentions this issue: go/packages: trim errors returned by go list

@golang golang locked and limited conversation to collaborators Jun 19, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

3 participants