We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
The goimports will retain blank lines and multiple groups will exist after formatting.
testdata in.go:
import ( "fmt" "github.com/foo/a" "github.com/foo/b" "go.pkg.com/bar/x" "go.pkg.com/bar/y" "context" "github.com/foo/c" "go.pkg.com/bar/z" )
goimports -local go.pkg.com in.go output:
goimports -local go.pkg.com in.go
package foo import ( "fmt" "github.com/foo/a" "github.com/foo/b" "context" "go.pkg.com/bar/x" "go.pkg.com/bar/y" "github.com/foo/c" "go.pkg.com/bar/z" )
Would like a tool to automate the removal of blank lines and regrouping.
Add a -r flag, goimports -r -local go.pkg.com in.go output:
-r
goimports -r -local go.pkg.com in.go
package foo import ( "context" "fmt" "github.com/foo/a" "github.com/foo/b" "github.com/foo/c" "go.pkg.com/bar/x" "go.pkg.com/bar/y" "go.pkg.com/bar/z" )
It's easy to implement, here's the pseudo-code:
// add flag regroup = flag.Bool("r", false, "remove blank line and regroup imports") func processFile() { if *regroup { src = removeBlankLineInImport(src) } // origin imports.Process res, err := imports.Process(target, src, opt) } func removeBlankLineInImport(src []byte) []byte { // 1. parset AST // 2. find first import block start and end line // 3. rewrite src, remove blank line in import block }
No breaking changes, and even regrouping keeps compatibility with the original goimports rules.
We forked goimports in our internal project and added this feature so that if the proposal is accepted, I can submit a PR.
The text was updated successfully, but these errors were encountered:
No branches or pull requests
current
The goimports will retain blank lines and multiple groups will exist after formatting.
testdata in.go:
goimports -local go.pkg.com in.go
output:expect
Would like a tool to automate the removal of blank lines and regrouping.
Add a
-r
flag,goimports -r -local go.pkg.com in.go
output:implement
It's easy to implement, here's the pseudo-code:
No breaking changes, and even regrouping keeps compatibility with the original goimports rules.
We forked goimports in our internal project and added this feature so that if the proposal is accepted, I can submit a PR.
The text was updated successfully, but these errors were encountered: