Skip to content
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

[go] goimport that check and replace specific import #118

Open
at15 opened this issue Jan 1, 2020 · 7 comments
Open

[go] goimport that check and replace specific import #118

at15 opened this issue Jan 1, 2020 · 7 comments
Assignees
Labels
area/go phase/proposal someone has an idea, no one has taken it type/new-package
Milestone

Comments

@at15
Copy link
Member

at15 commented Jan 1, 2020

Now I use goimport instead of gofmt when formatting code because it checks import and do the sorting. However I have some new use cases:

  • replace specific import because they were added by IDE when there are imports with similar name. Especially when your dependency depends on its own fork of your other dependency, e.g. assert.
  • group import into multiple groups, e.g. protobuf, third party dependency, packages inside the project
  • enforce import alias, e.g. protobuf packages should be named to xxxpb

Should put it under gommon fmt or gommon gofmt

@at15 at15 added type/new-package area/go phase/proposal someone has an idea, no one has taken it labels Jan 1, 2020
@at15 at15 added this to the future milestone Jan 1, 2020
@at15 at15 self-assigned this Jan 1, 2020
@at15
Copy link
Member Author

at15 commented Feb 28, 2020

I should be part of #75

@at15
Copy link
Member Author

at15 commented Feb 29, 2020

@at15
Copy link
Member Author

at15 commented Mar 6, 2020

Also there is one checking if specific import is allowed https://github.com/fatih/faillint

@at15
Copy link
Member Author

at15 commented Mar 8, 2020

@at15
Copy link
Member Author

at15 commented Mar 8, 2020

https://pkg.go.dev/golang.org/x/tools/go/ast/astutil?tab=doc#AddImport astutil contains add and remove imports, looks pretty good ... not sure if we can do something similar to goimports using that

@at15 at15 modified the milestones: future, 0.0.15 Mar 8, 2020
@at15
Copy link
Member Author

at15 commented Mar 8, 2020

https://github.com/cockroachdb/crlfmt/blob/master/main.go#L238 found one from cockroachdb, crlfmt

@at15
Copy link
Member Author

at15 commented Mar 9, 2020

https://github.com/OpenPeeDeeP/depguard found from golint ci

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/go phase/proposal someone has an idea, no one has taken it type/new-package
Projects
None yet
Development

No branches or pull requests

1 participant