Skip to content

Add prefix-current-module to goimports #931

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

Closed
sagikazarmark opened this issue Jan 21, 2020 · 8 comments
Closed

Add prefix-current-module to goimports #931

sagikazarmark opened this issue Jan 21, 2020 · 8 comments
Labels
enhancement New feature or improvement

Comments

@sagikazarmark
Copy link

I'd like to add a bool option prefix-current-module to the goimports config.

It would basically check if the linted package is a module, and slap the module path (based on go.mod if exists) to the list of local prefixes. It would make the configuration more portable.

WDYT?

@ernado ernado added the enhancement New feature or improvement label Feb 2, 2020
@ernado
Copy link
Member

ernado commented Feb 2, 2020

Thank you for idea, seems reasonable.
Feel free to open PR.

@sagikazarmark
Copy link
Author

@ernado are you aware of any tools that detect module paths in GolangCI?

If not, I would pull in https://github.com/gobuffalo/here as a dependency. It doesn't have any additional dependencies that's not already a dependency in GolangCI.

@ernado
Copy link
Member

ernado commented Feb 4, 2020

I think that package name should be already in analysis context, but I'm not sure.

@sagikazarmark
Copy link
Author

The package name is not enough, I need the root module path and as far as I can tell, it's not available in the context.

@stale
Copy link

stale bot commented Feb 6, 2021

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.

@stale stale bot added the stale No recent correspondence or work activity label Feb 6, 2021
@sagikazarmark
Copy link
Author

Sadly, I haven't beeb able to work on it, but it'd still be a good feature.

@stale stale bot removed the stale No recent correspondence or work activity label Feb 6, 2021
@stale
Copy link

stale bot commented Mar 30, 2022

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.

@stale stale bot added the stale No recent correspondence or work activity label Mar 30, 2022
@ldez ldez removed the stale No recent correspondence or work activity label Mar 30, 2022
@ldez
Copy link
Member

ldez commented Dec 22, 2024

The problem can be solved with gci instead of goimports:

linters:
  enable:
    - gci

linters-settings:
  gci:
    sections:
      - standard
      - default
      - localmodule

https://golangci-lint.run/usage/linters/#gci

@ldez ldez closed this as completed Dec 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or improvement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants