Skip to content

Commit 04aec4f

Browse files
authored
gci: fix section parsing (#5407)
1 parent 5984eab commit 04aec4f

File tree

3 files changed

+27
-3
lines changed

3 files changed

+27
-3
lines changed

pkg/goformatters/gci/internal/config/config.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88

99
"github.com/daixiang0/gci/pkg/config"
1010
"github.com/daixiang0/gci/pkg/section"
11+
sectioni "github.com/golangci/golangci-lint/pkg/goformatters/gci/internal/section"
1112
)
1213

1314
var defaultOrder = map[string]int{
@@ -39,12 +40,12 @@ type YamlConfig struct {
3940
func (g YamlConfig) Parse() (*Config, error) {
4041
var err error
4142

42-
sections, err := section.Parse(g.SectionStrings)
43+
sections, err := sectioni.Parse(g.SectionStrings)
4344
if err != nil {
4445
return nil, err
4546
}
4647
if sections == nil {
47-
sections = section.DefaultSections()
48+
sections = sectioni.DefaultSections()
4849
}
4950
if err := configureSections(sections, g.ModPath); err != nil {
5051
return nil, err
@@ -63,7 +64,7 @@ func (g YamlConfig) Parse() (*Config, error) {
6364
})
6465
}
6566

66-
sectionSeparators, err := section.Parse(g.SectionSeparatorStrings)
67+
sectionSeparators, err := sectioni.Parse(g.SectionSeparatorStrings)
6768
if err != nil {
6869
return nil, err
6970
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package section
2+
3+
import "github.com/daixiang0/gci/pkg/section"
4+
5+
func DefaultSections() section.SectionList {
6+
return section.SectionList{Standard{}, section.Default{}}
7+
}
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
//go:build go1.24
2+
3+
//golangcitest:args -Egci
4+
//golangcitest:expected_exitcode 0
5+
package testdata
6+
7+
import (
8+
"crypto/sha3"
9+
"errors"
10+
"fmt"
11+
)
12+
13+
func _() {
14+
fmt.Print(errors.New("x"))
15+
sha3.New224()
16+
}

0 commit comments

Comments
 (0)