goimports grouping/ordering problem
As you can see on this issue golang/go#20818, goimports has a problem about grouping/ordering import lines.
But we have to determine several specifications to resolve this problem, and a lot of people have been discussing for about 4 years on the issue.
An example solution
https://github.com/rinchsan/gosimports
A tool named gosimports provides one example solution for the issue.
gosimports stands for "simpler goimports", putting "s" between "go" and "imports" of "goimports".
What gosimports does
When you have a file like this:
package main
import (
"fmt"
"golang.org/x/sync/errgroup"
"context"
)
func main() {
fmt.Println(errgroup.WithContext(context.Background()))
}
gosimports will re-group and re-order import lines like below:
package main
import (
"context"
"fmt"
"golang.org/x/sync/errgroup"
)
func main() {
fmt.Println(errgroup.WithContext(context.Background()))
}
while original goimports does not.
Top comments (0)