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
Milestone

Comments

@gertcuykens
Copy link
Contributor

@gertcuykens 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 this to the Backlog milestone Oct 25, 2019
@mvdan

This comment has been minimized.

Copy link
Member

@mvdan 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

This comment has been minimized.

Copy link
Member

@mvdan 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 Oct 27, 2019
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.