Skip to content

Commit 1612ffe

Browse files
authored
fix issue when duplicate imports (#99)
Signed-off-by: Loong <[email protected]>
1 parent 674138d commit 1612ffe

File tree

4 files changed

+26
-0
lines changed

4 files changed

+26
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
sections:
2+
- Standard
3+
- Default
4+
- Prefix(github.com/daixiang0)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package main
2+
import (
3+
"fmt"
4+
5+
g "github.com/golang"
6+
7+
a "github.com/daixiang0/gci"
8+
"github.com/daixiang0/gci"
9+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package main
2+
import (
3+
"fmt"
4+
5+
g "github.com/golang"
6+
7+
"github.com/daixiang0/gci"
8+
a "github.com/daixiang0/gci"
9+
)

pkg/parse/parse.go

+4
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ func (l ImportList) Len() int {
2020
}
2121

2222
func (l ImportList) Less(i, j int) bool {
23+
if strings.Compare(l[i].Path, l[j].Path) == 0 {
24+
return strings.Compare(l[i].Name, l[j].Name) < 0
25+
}
26+
2327
return strings.Compare(l[i].Path, l[j].Path) < 0
2428
}
2529

0 commit comments

Comments
 (0)