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: go list on a package with an empty file doesn't return deps #35973

Closed
stamblerre opened this issue Dec 4, 2019 · 3 comments
Closed

cmd/go: go list on a package with an empty file doesn't return deps #35973

stamblerre opened this issue Dec 4, 2019 · 3 comments
Assignees
Labels
Milestone

Comments

@stamblerre
Copy link
Contributor

@stamblerre stamblerre commented Dec 4, 2019

When a file in package is empty, go list fails with this error:

$ go list -e -json ~/mod1
{
	"Dir": "$HOME/rstambler/mod1",
	"ImportPath": "mod1",
	...
	"GoFiles": [
		"const.go",
		"mod1.go"
	],
	"Error": {
		"ImportStack": [
			"mod1"
		],
		"Pos": "",
		"Err": "\nmod2.go:1:1: expected 'package', found 'EOF'"
	}
}

Where mod1 contains files const.go, mod1.go, and mod2.go, the empty file. We had previously worked around this in go/packages (see CL 201220) by adding the file in the error message to the list of GoFiles. However, it has recently been noticed that this result is also missing the list of dependencies for the given package. Would it be possible for go list to return the correct list of deps for the other files in the package?

/cc @heschik @matloob

@gopherbot

This comment has been minimized.

Copy link

@gopherbot gopherbot commented Dec 5, 2019

Change https://golang.org/cl/209978 mentions this issue: go/packages: revert "handle invalid files in overlays"

gopherbot pushed a commit to golang/tools that referenced this issue Dec 5, 2019
This reverts commit 6f5e273, golang.org/cl/201220.

Reason for revert: Produces unusable Package results. See golang/go#35949 and golang/go#35973.

Fixes golang/go#35949.

Change-Id: Ic4632fe7f00366b1edf59840c83160d66499ba12
Reviewed-on: https://go-review.googlesource.com/c/tools/+/209978
Run-TryBot: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
@gopherbot

This comment has been minimized.

Copy link

@gopherbot gopherbot commented Dec 5, 2019

Change https://golang.org/cl/210097 mentions this issue: cmd/go: include imports in 'go list -e' output even after parse errors

@gopherbot gopherbot closed this in 993ec7f Dec 5, 2019
@gopherbot

This comment has been minimized.

Copy link

@gopherbot gopherbot commented Dec 6, 2019

Change https://golang.org/cl/210206 mentions this issue: go/packages: revert "handle invalid files in overlays"

gopherbot pushed a commit to golang/tools that referenced this issue Dec 6, 2019
This reverts commit 6f5e273, golang.org/cl/201220.

Reason for revert: Produces unusable Package results. See golang/go#35949 and golang/go#35973.

Fixes golang/go#35949.

Change-Id: Ic4632fe7f00366b1edf59840c83160d66499ba12
Reviewed-on: https://go-review.googlesource.com/c/tools/+/209978
Run-TryBot: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
(cherry picked from commit 427c522)
Reviewed-on: https://go-review.googlesource.com/c/tools/+/210206
Reviewed-by: Heschi Kreinick <heschi@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.