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/vet: mishandling of top block comment #46169
Comments
BSL license stipulates that every source file should have one: > All source files under BSL have a Change Date and the name of an Open Source license in the header. The Change Date specifies when the source file changes from BSL to the specified Open Source license. On the Change Date, or the fourth anniversary of the first publicly available distribution of the code under the BSL, whichever comes first, the code automatically becomes available under the Change License (i.e., an Open Source license). Solution: use an automatic header insertion tool (go-license) and [go-header](https://github.com/denis-tingaikin/go-header) lint (golangci-run includes it) Originally, I wanted to have empty comment lines between clauses of the license header (copyright, reference to LICENSE and Change Date clause), but go-license and go-header didn't quite agree on how to handle empty lines and go-header was complaining and failing the check. They did agree when I used a block comment to insert the license, but `go vet` didn't: golang/go#46169 So I just removed the empty comment lines to get this done for now. Closes yrashk-archived#13
I believe @rsc wrote this analysis. |
The "buildtag" checker seems to process only line comments starting with "//" when determining the cutoff point. It needs to be extent to support block comments. // Copyright 2020 The Go Authors. All rights reserved. // +build BTW, you may be using the old "buildtag" checker, although the new one will have the same issue. |
I tried to use block comments becausr https://github.com/denis-tingajkin/go-header lint and https://github.com/palantir/go-license couldn't agree in how to treat empty lines in those headers. They agreed when block comments were used. But go vet doesn't agree with the build tag in this case. So I currently settled on a header without new lines. Not perfect, but good enough for now. But I found this behavior to be off as it's specified to be a comment, and not limited to line comments |
The documentation says
@yrashk Did you perhaps encounter some other documentation that did not specify the exact type of comments in question? |
You are right, I overlooked that indeed.
…On Mon., May 24, 2021, 4:32 p.m. Zvonimir ***@***.***> wrote:
The documentation <https://golang.org/cmd/go/#hdr-Build_constraints> says
Constraints may appear in any kind of source file (not just Go), but they
must appear near the top of the file, preceded only by blank lines and
other **line** comments.
@yrashk <https://github.com/yrashk> Did you perhaps encountered some
other documentation that did not specify the exact type of comments in
question?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#46169 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAADREYZRBTROLXV5HGEI3TPLOZ7ANCNFSM444TDRNA>
.
|
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Running
go vet
on this file:What did you expect to see?
Nothing
What did you see instead?
My experimentation shows that if I convert the license header to the single-line form (
//
), it works fine -- but it doesn'twith block comments, which I think it should, unless I am missing something.
The text was updated successfully, but these errors were encountered: