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: build, vet, fmt, test print path format ./example.go:1:1: #35144

Closed
gertcuykens opened this issue Oct 24, 2019 · 2 comments
Closed

cmd/go: build, vet, fmt, test print path format ./example.go:1:1: #35144

gertcuykens opened this issue Oct 24, 2019 · 2 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@gertcuykens
Copy link
Contributor

gertcuykens commented Oct 24, 2019

create a file main.go

package main
k
func main(){}

Then try the following

% go build
./main.go:2:1: syntax error: non-declaration statement outside function body
% go vet
vet: ./main.go:2:1: expected declaration, found k
% go test
./main.go:2:1: syntax error: non-declaration statement outside function body 

So far so good everything consistent except for the vet: thingy in the beginning of the vet output instead of ./main.go:2:1: vet: expected declaration, found k but I let that slight for now :) Most important for vscode and my terminal is path consistency namely every path has at least one / in it

Now do go test again but rename the file to main_test.go

% go test
main_test.go:2:1: expected declaration, found k

Here we break the internet because vscode and terminals can't figure out that it's a path because ./ is stripped so you can't click on it anymore to open the src file in that location.

(ref: https://groups.google.com/forum/#!topic/golang-dev/ZbTYwDSlGvQ)

EDIT:

I think we need to start with just go vet consistency in test vs non test files to begin with.

output go vet on a .go file vs _test.go file

% go vet
vet: ./main.go:11:1: expected declaration, found k (and 1 more errors)

% go vet
main_test.go:11:1: expected declaration, found k
main_test.go:43:2: expected declaration, found err

end goal should be this in all cases, to make vet consistent with itself and other tools :)

./main.go:11:1: vet: expected declaration, found k
@jayconrod jayconrod added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Oct 25, 2019
@jayconrod jayconrod added this to the Backlog milestone Oct 25, 2019
@mvdan
Copy link
Member

mvdan commented Oct 25, 2019

I think this is a duplicate of #24344. Note that that was a while ago, probably before go test started running vet. Still, it seems like the same issue to me.

@mvdan
Copy link
Member

mvdan commented Oct 27, 2019

OP replied on that previous issue, so I'll assume he agrees this is a duplicate :)

@mvdan mvdan closed this as completed Oct 27, 2019
@golang golang locked and limited conversation to collaborators Oct 26, 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

4 participants