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/lint: golint does not recognize Unwrap methods #36997

Closed
perillo opened this issue Feb 3, 2020 · 8 comments
Closed

x/lint: golint does not recognize Unwrap methods #36997

perillo opened this issue Feb 3, 2020 · 8 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@perillo
Copy link
Contributor

perillo commented Feb 3, 2020

golint does not complain if a method implementing know interfaces is not documented.
However when I define the Unwrap method, it complains:

exported method Error.Unwrap should have comment or be unexported

By the way, how I'm supposed to document the method?

// Unwrap implements support for error unwrapping.

or

// Unwrap implements the Unwrapper interface.

?

@gopherbot gopherbot added this to the Unreleased milestone Feb 3, 2020
@cagedmantis cagedmantis modified the milestones: Unreleased, Backlog Feb 7, 2020
@cagedmantis cagedmantis added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Feb 7, 2020
@cagedmantis
Copy link
Contributor

Could you provide more information for this issue? Could you provide an example of the code that produced the error, preferably as a Go playground link?

@perillo
Copy link
Contributor Author

perillo commented Feb 7, 2020

Sure, sorry.

https://play.golang.org/p/8Zy-WTR7J9B

golint will report:

test/unwrap.go:17:1: exported method Error.Unwrap should have comment or be unexported

Note how there is no warning about the Error method not having a comment since it is a well know interface.

@perillo
Copy link
Contributor Author

perillo commented Feb 7, 2020

Here is the code that should be updated:
https://github.com/golang/lint/blob/master/lint.go#L836

Thanks

@cagedmantis
Copy link
Contributor

Thank you for the clarification.

@cagedmantis cagedmantis added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. and removed WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. labels Feb 7, 2020
@cagedmantis
Copy link
Contributor

/cc @ianthehat @matloob

@matloob
Copy link
Contributor

matloob commented Feb 7, 2020

Lint is really noisy and my preference is to keep its behavior fixed. If you want to send a CL to add Unwrap to the list of known methods I'd be okay with it.

@mvdan
Copy link
Member

mvdan commented May 8, 2021

Thank you for submitting this issue! As per #38968, we are freezing and deprecating golint. There's no drop-in replacement to golint per se, but you should find that Staticcheck works well in encouraging good Go code, much like golint did in the past, since it also includes style checks. There's always gofmt and go vet too, of course.

If you would like to contribute further, I'd encourage you to engage Staticcheck's issue tracker or look at vet's open issues, as they are both actively maintained. If you have an idea that doesn't fit into either of those tools, you could look at other Go linters, or write your own - these days it's fairly straightforward with go/analysis.

To help avoid confusion, I'm closing all golint issues before we freeze its repository. If you have any feedback, you can leave a comment on the proposal thread where it was decided to deprecate golint - though note that the proposal has been accepted for nearly a year. Thanks!

@mvdan mvdan closed this as completed May 8, 2021
@perillo
Copy link
Contributor Author

perillo commented May 8, 2021

Thanks for the notification.

@golang golang locked and limited conversation to collaborators May 8, 2022
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

5 participants