golangci-lint icon indicating copy to clipboard operation
golangci-lint copied to clipboard

Add `prefix-current-module` to goimports

Open sagikazarmark opened this issue 5 years ago • 7 comments

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?

sagikazarmark avatar Jan 21 '20 08:01 sagikazarmark

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

ernado avatar Feb 02 '20 22:02 ernado

@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.

sagikazarmark avatar Feb 03 '20 11:02 sagikazarmark

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

ernado avatar Feb 04 '20 15:02 ernado

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.

sagikazarmark avatar Feb 04 '20 21:02 sagikazarmark

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[bot] avatar Feb 06 '21 15:02 stale[bot]

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

sagikazarmark avatar Feb 06 '21 18:02 sagikazarmark

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[bot] avatar Mar 30 '22 06:03 stale[bot]