Skip to content

Commit a59b22e

Browse files
committed
fix: walkdir on Windows is buggy
1 parent e8172d9 commit a59b22e

File tree

6 files changed

+30
-27
lines changed

6 files changed

+30
-27
lines changed

.goreleaser.yml

+7-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,13 @@ builds:
1616
env:
1717
- CGO_ENABLED=0
1818
archives:
19-
- replacements:
20-
amd64: x86_64
19+
- name_template: >-
20+
{{- .ProjectName }}_
21+
{{- title .Os }}_
22+
{{- if eq .Arch "amd64" }}x86_64
23+
{{- else if eq .Arch "386" }}i386
24+
{{- else }}{{ .Arch }}{{ end }}
25+
{{- if .Arm }}v{{ .Arm }}{{ end -}}
2126
dockers:
2227
- image_templates:
2328
- greut/eclint:latest

definition.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ type definition struct {
2626
InsideBlockComment bool
2727
}
2828

29-
func newDefinition(d *editorconfig.Definition) (*definition, error) { //nolint:cyclop,gocognit
29+
func newDefinition(d *editorconfig.Definition) (*definition, error) { //nolint:cyclop
3030
def := &definition{
3131
Definition: *d,
3232
TabWidth: d.TabWidth,

files.go

+12-11
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ import (
55
"context"
66
"errors"
77
"fmt"
8+
"io/fs"
89
"os"
910
"os/exec"
1011

1112
"github.com/go-logr/logr"
12-
"github.com/karrick/godirwalk"
1313
)
1414

1515
// ListFilesContext lists the files in an asynchronous fashion
@@ -53,16 +53,17 @@ func WalkContext(ctx context.Context, paths ...string) (<-chan string, <-chan er
5353
break
5454
}
5555

56-
err := godirwalk.Walk(path, &godirwalk.Options{
57-
Callback: func(filename string, de *godirwalk.Dirent) error {
58-
select {
59-
case filesChan <- filename:
60-
return nil
61-
case <-ctx.Done():
62-
return fmt.Errorf("walking dir got interrupted: %w", ctx.Err())
63-
}
64-
},
65-
Unsorted: true,
56+
err := fs.WalkDir(os.DirFS(path), ".", func(filename string, _ fs.DirEntry, err error) error {
57+
if err != nil {
58+
return err
59+
}
60+
61+
select {
62+
case filesChan <- filename:
63+
return nil
64+
case <-ctx.Done():
65+
return fmt.Errorf("walking dir got interrupted: %w", ctx.Err())
66+
}
6667
})
6768
if err != nil {
6869
errChan <- err

go.mod

+3-4
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,10 @@ require (
77
github.com/go-logr/logr v1.2.4
88
github.com/gogs/chardet v0.0.0-20211120154057-b7413eaefb8f
99
github.com/google/go-cmp v0.5.9
10-
github.com/karrick/godirwalk v1.17.0
1110
github.com/logrusorgru/aurora v2.0.3+incompatible
1211
github.com/mattn/go-colorable v0.1.13
13-
golang.org/x/term v0.8.0
14-
golang.org/x/text v0.9.0
12+
golang.org/x/term v0.11.0
13+
golang.org/x/text v0.12.0
1514
k8s.io/klog/v2 v2.100.1
1615
)
1716

@@ -22,7 +21,7 @@ require (
2221
github.com/mattn/go-isatty v0.0.16 // indirect
2322
github.com/pmezard/go-difflib v1.0.0 // indirect
2423
golang.org/x/mod v0.10.0 // indirect
25-
golang.org/x/sys v0.8.0 // indirect
24+
golang.org/x/sys v0.11.0 // indirect
2625
gopkg.in/ini.v1 v1.67.0 // indirect
2726
gopkg.in/yaml.v3 v3.0.1 // indirect
2827
)

go.sum

+6-8
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ github.com/hashicorp/errwrap v1.0.0 h1:hLrqtEDnRye3+sgx6z4qVLNuviH3MR5aQ0ykNJa/U
1313
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
1414
github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo=
1515
github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM=
16-
github.com/karrick/godirwalk v1.17.0 h1:b4kY7nqDdioR/6qnbHQyDvmA17u5G1cZ6J+CZXwSWoI=
17-
github.com/karrick/godirwalk v1.17.0/go.mod h1:j4mkqPuvaLI8mp1DroR3P6ad7cyYd4c1qeJ3RV7ULlk=
1816
github.com/logrusorgru/aurora v2.0.3+incompatible h1:tOpm7WcpBTn4fjmVfgpQq0EfczGlG91VSDkswnjF5A8=
1917
github.com/logrusorgru/aurora v2.0.3+incompatible/go.mod h1:7rIyQOR62GCctdiQpZ/zOJlFyk6y+94wXzv6RNZgaR4=
2018
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
@@ -27,12 +25,12 @@ github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5Cc
2725
golang.org/x/mod v0.10.0 h1:lFO9qtOdlre5W1jxS3r/4szv2/6iXxScdzjoBMXNhYk=
2826
golang.org/x/mod v0.10.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
2927
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
30-
golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU=
31-
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
32-
golang.org/x/term v0.8.0 h1:n5xxQn2i3PC0yLAbjTpNT85q/Kgzcr2gIoX9OrJUols=
33-
golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo=
34-
golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE=
35-
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
28+
golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM=
29+
golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
30+
golang.org/x/term v0.11.0 h1:F9tnn/DA/Im8nCwm+fX+1/eBwi4qFjRT++MhtVC4ZX0=
31+
golang.org/x/term v0.11.0/go.mod h1:zC9APTIj3jG3FdV/Ons+XE1riIZXG4aZ4GTHiPZJPIU=
32+
golang.org/x/text v0.12.0 h1:k+n5B8goJNdU7hSvEtMUz3d1Q6D/XW4COJSJR6fN0mc=
33+
golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
3634
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
3735
gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA=
3836
gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=

print.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
)
1313

1414
// PrintErrors is the rich output of the program.
15-
func PrintErrors(ctx context.Context, opt *Option, filename string, errs []error) error { //nolint:gocognit
15+
func PrintErrors(ctx context.Context, opt *Option, filename string, errs []error) error {
1616
counter := 0
1717

1818
log := logr.FromContextOrDiscard(ctx)

0 commit comments

Comments
 (0)