Skip to content
This repository has been archived by the owner on May 9, 2021. It is now read-only.

Suggestion: add -tags flag to support build tags #358

Closed
mna opened this issue Nov 29, 2017 · 2 comments
Closed

Suggestion: add -tags flag to support build tags #358

mna opened this issue Nov 29, 2017 · 2 comments

Comments

@mna
Copy link

mna commented Nov 29, 2017

Hello,

At the moment there's no way to specify build tags when running golint. When running on specific files this is no problem (it will lint whatever file is specified), but that would be very useful when linting packages. Otherwise it silently ignores the files in the package that are not loaded due to a missing build tag.

I'd suggest adding a command-line flag called -tags, the same as for the go build flag, that would take a space-separated list of tags to define.

AFAICS, the only change required is in golint/golint.go, to set the specified build tags on a custom build.Context struct and use that context to import code (could even be set directly on build.Default as this is a command-line tool, doesn't impact anything else).

Let me know if that would be a welcome change, happy to provide a PR if that is the case.

Thanks,
Martin

@vimalloc
Copy link

I would really like to see this change. Without it, I'm not able to see any errors in my integration tests that are setup with // +build integration unless I actually try to run them. If we had -tags support for golint, I would be able to set the build tags and view the errors in real time in my editor.

@mvdan
Copy link
Member

mvdan commented May 8, 2021

Thank you for submitting this issue! As per golang/go#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 issues before we freeze the 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
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants