Skip to content

Commit

Permalink
simplify goimports
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilsk committed Apr 24, 2021
1 parent f74a669 commit f8c79ef
Showing 1 changed file with 1 addition and 12 deletions.
13 changes: 1 addition & 12 deletions internal/imports/sortimports.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,7 @@ func sortImports(localPrefix string, fset *token.FileSet, f *ast.File) {
continue
}

// Identify and sort runs of specs on successive lines.
i := 0
specs := d.Specs[:0]
for j, s := range d.Specs {
if j > i && fset.Position(s.Pos()).Line > 1+fset.Position(d.Specs[j-1].End()).Line {
// j begins a new run. End this one.
specs = append(specs, sortSpecs(localPrefix, fset, f, d.Specs[i:j])...)
i = j
}
}
specs = append(specs, sortSpecs(localPrefix, fset, f, d.Specs[i:])...)
d.Specs = specs
d.Specs = sortSpecs(localPrefix, fset, f, d.Specs)

// Deduping can leave a blank line before the rparen; clean that up.
if len(d.Specs) > 0 {
Expand Down

0 comments on commit f8c79ef

Please sign in to comment.