this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

all: check the filepath.Walk error parameter

As documented by filepath.WalkFunc:

The err argument reports an error related to path, signaling that
Walk will not walk into that directory. The function can decide how
to handle that error; as described earlier, returning the error will
cause Walk to stop walking the entire tree.

We want the conservative behavior which is also used in all examples:
to stop if any error is encountered. Do that.

This removes four warnings from staticcheck, which correctly pointed out
that the value of the "err" parameter was being overwritten before being used.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
Change-Id: Ie1bce1f5f6e820c9bb203226211ad9a9ec113eba
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/537224
Unity-Result: CUEcueckoo <cueckoo@cuelang.org>
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
Reviewed-by: Paul Jolly <paul@myitcv.io>

+14
+3
cmd/cue/cmd/get_go.go
··· 580 580 for _, o := range p.CompiledGoFiles { 581 581 root := filepath.Dir(o) 582 582 err := filepath.Walk(root, func(path string, fi os.FileInfo, err error) error { 583 + if err != nil { 584 + return err 585 + } 583 586 if fi.IsDir() && path != root { 584 587 return filepath.SkipDir 585 588 }
+4
cmd/cue/cmd/script_test.go
··· 47 47 func TestLatest(t *testing.T) { 48 48 root := filepath.Join("testdata", "script") 49 49 filepath.Walk(root, func(fullpath string, info os.FileInfo, err error) error { 50 + if err != nil { 51 + t.Error(err) 52 + return nil 53 + } 50 54 if !strings.HasSuffix(fullpath, ".txt") || 51 55 strings.HasPrefix(filepath.Base(fullpath), "fix") { 52 56 return nil
+4
doc/tutorial/basics/script_test.go
··· 19 19 // even if still valid in backwards compatibility mode. 20 20 func TestLatest(t *testing.T) { 21 21 filepath.Walk(".", func(fullpath string, info os.FileInfo, err error) error { 22 + if err != nil { 23 + t.Error(err) 24 + return nil 25 + } 22 26 if !strings.HasSuffix(fullpath, ".txt") { 23 27 return nil 24 28 }
+3
doc/tutorial/kubernetes/tut_test.go
··· 240 240 241 241 // Compare the output in the temp directory with the quick output. 242 242 err = filepath.Walk(dir, func(path string, info os.FileInfo, err error) error { 243 + if err != nil { 244 + t.Fatal(err) 245 + } 243 246 if filepath.Ext(path) != ".cue" { 244 247 return nil 245 248 }