mgechev / revive

🔥 ~6x faster, stricter, configurable, extensible, and beautiful drop-in replacement for golint
https://revive.run
MIT License
4.79k stars 278 forks source link

import-alias-naming incorrect? #919

Closed marcelloh closed 11 months ago

marcelloh commented 11 months ago

Describe the bug https://go.dev/blog/package-names On this page should be something mentioned about alias naming, but I can't find it. Also: when I try this: ^[a-z][\w]{0,}$ it still complains about libTracer not matching it. import-alias-naming: import name (libTracer) must match the regular expression: ^[a-z][\w]{0

To Reproduce I have it running from golangci-lint

      # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#import-alias-naming
      - name: import-alias-naming
        arguments: "^[a-z][\\w]{0,}$"

Expected behavior I expect a working solution, where revive doesn't complain about my imports.

Logs

Desktop (please complete the following information):

Additional context

marcelloh commented 11 months ago

found out that this works, which is good enough for me: "^[a-z][a-zA-Z0-9]*$"

denisvmedia commented 11 months ago

@marcelloh the page you are referring to indeed only speaks about the package names, but is there any good reason for the aliases to not follow the idiomatic rules of the package names? In the end alias is an alias of the package name, in other words it is a package name as well.

marcelloh commented 11 months ago

As it works for me now with a proper regex, I feel that it doesn't matter. (and not so much fan of _)