Skip to content

Commit

Permalink
fix: walkdir on Windows is buggy
Browse files Browse the repository at this point in the history
  • Loading branch information
greut committed Aug 29, 2023
1 parent e8172d9 commit a59b22e
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 27 deletions.
9 changes: 7 additions & 2 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,13 @@ builds:
env:
- CGO_ENABLED=0
archives:
- replacements:
amd64: x86_64
- name_template: >-
{{- .ProjectName }}_
{{- title .Os }}_
{{- if eq .Arch "amd64" }}x86_64
{{- else if eq .Arch "386" }}i386
{{- else }}{{ .Arch }}{{ end }}
{{- if .Arm }}v{{ .Arm }}{{ end -}}
dockers:
- image_templates:
- greut/eclint:latest
Expand Down
2 changes: 1 addition & 1 deletion definition.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ type definition struct {
InsideBlockComment bool
}

func newDefinition(d *editorconfig.Definition) (*definition, error) { //nolint:cyclop,gocognit
func newDefinition(d *editorconfig.Definition) (*definition, error) { //nolint:cyclop
def := &definition{
Definition: *d,
TabWidth: d.TabWidth,
Expand Down
23 changes: 12 additions & 11 deletions files.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import (
"context"
"errors"
"fmt"
"io/fs"
"os"
"os/exec"

"github.com/go-logr/logr"
"github.com/karrick/godirwalk"
)

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

err := godirwalk.Walk(path, &godirwalk.Options{
Callback: func(filename string, de *godirwalk.Dirent) error {
select {
case filesChan <- filename:
return nil
case <-ctx.Done():
return fmt.Errorf("walking dir got interrupted: %w", ctx.Err())
}
},
Unsorted: true,
err := fs.WalkDir(os.DirFS(path), ".", func(filename string, _ fs.DirEntry, err error) error {
if err != nil {
return err
}

select {
case filesChan <- filename:
return nil
case <-ctx.Done():
return fmt.Errorf("walking dir got interrupted: %w", ctx.Err())
}
})
if err != nil {
errChan <- err
Expand Down
7 changes: 3 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@ require (
github.com/go-logr/logr v1.2.4
github.com/gogs/chardet v0.0.0-20211120154057-b7413eaefb8f
github.com/google/go-cmp v0.5.9
github.com/karrick/godirwalk v1.17.0
github.com/logrusorgru/aurora v2.0.3+incompatible
github.com/mattn/go-colorable v0.1.13
golang.org/x/term v0.8.0
golang.org/x/text v0.9.0
golang.org/x/term v0.11.0
golang.org/x/text v0.12.0
k8s.io/klog/v2 v2.100.1
)

Expand All @@ -22,7 +21,7 @@ require (
github.com/mattn/go-isatty v0.0.16 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
golang.org/x/mod v0.10.0 // indirect
golang.org/x/sys v0.8.0 // indirect
golang.org/x/sys v0.11.0 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
14 changes: 6 additions & 8 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ github.com/hashicorp/errwrap v1.0.0 h1:hLrqtEDnRye3+sgx6z4qVLNuviH3MR5aQ0ykNJa/U
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo=
github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM=
github.com/karrick/godirwalk v1.17.0 h1:b4kY7nqDdioR/6qnbHQyDvmA17u5G1cZ6J+CZXwSWoI=
github.com/karrick/godirwalk v1.17.0/go.mod h1:j4mkqPuvaLI8mp1DroR3P6ad7cyYd4c1qeJ3RV7ULlk=
github.com/logrusorgru/aurora v2.0.3+incompatible h1:tOpm7WcpBTn4fjmVfgpQq0EfczGlG91VSDkswnjF5A8=
github.com/logrusorgru/aurora v2.0.3+incompatible/go.mod h1:7rIyQOR62GCctdiQpZ/zOJlFyk6y+94wXzv6RNZgaR4=
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
Expand All @@ -27,12 +25,12 @@ github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5Cc
golang.org/x/mod v0.10.0 h1:lFO9qtOdlre5W1jxS3r/4szv2/6iXxScdzjoBMXNhYk=
golang.org/x/mod v0.10.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU=
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.8.0 h1:n5xxQn2i3PC0yLAbjTpNT85q/Kgzcr2gIoX9OrJUols=
golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo=
golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE=
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM=
golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.11.0 h1:F9tnn/DA/Im8nCwm+fX+1/eBwi4qFjRT++MhtVC4ZX0=
golang.org/x/term v0.11.0/go.mod h1:zC9APTIj3jG3FdV/Ons+XE1riIZXG4aZ4GTHiPZJPIU=
golang.org/x/text v0.12.0 h1:k+n5B8goJNdU7hSvEtMUz3d1Q6D/XW4COJSJR6fN0mc=
golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA=
gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
Expand Down
2 changes: 1 addition & 1 deletion print.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
)

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

log := logr.FromContextOrDiscard(ctx)
Expand Down

0 comments on commit a59b22e

Please sign in to comment.