-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Allow multiple main in same folder (for adhoc scripts, now fails with "main redeclared...") #1370
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
Comments
Hey, thank you for opening your first Issue ! 🙂 If you would like to contribute we have a guide for contributors. |
you can use skip-dirs in main golangci.yml: https://github.com/golangci/golangci-lint/blob/master/.golangci.yml#L137 and add individual golangci.yml for every sub project and just run all of them |
So provided the following project structure:
In order to make golangci-lint work, we need to run the following respectively:
And this is not straight forward |
because you need to put script1.go and script2.go into different packages
you structure incorrect, you cannot declare functions/variable with same name in same package. Just put to different packages |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
@SVilgelm can you explain how it's incorrect? I can have multiple |
golangci-lint works by package, it's the same thing as run Also, you can create multiple From the point of view of a package, it's impossible to have multiple functions/variables with the same name. Go is an app-oriented language, not a script-oriented language, so it's a bad practice to have a |
Is your feature request related to a problem? Please describe.
Sometimes we include several ad-hoc golang scripts in same folder, for example "scripts", to do ad-hoc jobs (executed them with
go run
).However, since golangci-lint cannot just ignore "packages", it will fail like this:
Currently, as a workaround, we run golangci-lint individually for each valid packages, and then run golangci-lint for those scripts one by one, this is sometimes cumbersome so I think it's better to do it in golangci-lint.
Describe the solution you'd like
Add an option to not treat these directories as packages, instead, scan them as golang files individually.
Additional context
#489 (comment)
The text was updated successfully, but these errors were encountered: