diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 68804c1..f5e06f6 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -7,7 +7,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - go-version: [1.12.x, 1.13.x] + go-version: [1.13.x, 1.14.x] os: [macos-latest, windows-latest, ubuntu-latest] steps: - name: Checkout Code diff --git a/dir.go b/dir.go index ecd75dd..95be28d 100644 --- a/dir.go +++ b/dir.go @@ -2,6 +2,7 @@ package here import ( "encoding/json" + "fmt" "os" "path/filepath" ) @@ -48,7 +49,7 @@ func (h Here) Dir(p string) (Info, error) { }) if err != nil { - return i, err + return i, fmt.Errorf("here.Dir: %s: %w", p, err) } return h.cache(i.ImportPath, func(p string) (Info, error) { @@ -72,12 +73,12 @@ func fromNonGoDir(dir string) (Info, error) { if nonGoDirRx.MatchString(err.Error()) { return i, nil } - return i, err + return i, fmt.Errorf("here.nonGoDir: %s: %w", dir, err) } if err := json.Unmarshal(b, &i.Module); err != nil { - return i, err + return i, fmt.Errorf("here.nonGoDir: %s: %w", dir, err) } - return i, err + return i, nil } diff --git a/go.mod b/go.mod index ebbb1db..26c922f 100644 --- a/go.mod +++ b/go.mod @@ -4,8 +4,8 @@ go 1.13 require ( github.com/davecgh/go-spew v1.1.1 // indirect - github.com/kr/pretty v0.1.0 // indirect - github.com/stretchr/testify v1.4.0 - gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 // indirect - gopkg.in/yaml.v2 v2.2.7 // indirect + github.com/kr/pretty v0.2.0 // indirect + github.com/stretchr/testify v1.5.1 + gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect + gopkg.in/yaml.v2 v2.2.8 // indirect ) diff --git a/go.sum b/go.sum index bfe6074..e4630f1 100644 --- a/go.sum +++ b/go.sum @@ -1,19 +1,22 @@ +github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= -github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pretty v0.2.0 h1:s5hAObm+yFO5uHYt5dYjxi2rXrsnmRpJx4OYvIWUaQs= +github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= -github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4= +github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= -gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= +gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.7 h1:VUgggvou5XRW9mHwD/yXxIYSMtY0zoKQf/v226p2nyo= -gopkg.in/yaml.v2 v2.2.7/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10= +gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/here.go b/here.go index e1d5765..69966a7 100644 --- a/here.go +++ b/here.go @@ -35,7 +35,7 @@ func run(n string, args ...string) ([]byte, error) { c.Stderr = ebb err := c.Run() if err != nil { - return nil, fmt.Errorf("%s: %s", err, ebb) + return nil, fmt.Errorf("%v %w: %s", c.Args, err, ebb) } return bb.Bytes(), nil @@ -48,7 +48,7 @@ func (h Here) cache(p string, fn func(string) (Info, error)) (Info, error) { } i, err := fn(p) if err != nil { - return i, err + return i, fmt.Errorf("here.cache: %s: %w", p, err) } h.infos.Store(p, i) return i, nil diff --git a/parse.go b/parse.go index 9227b93..9b6abcd 100644 --- a/parse.go +++ b/parse.go @@ -57,6 +57,7 @@ func (i Info) build(p, pkg, name string) (Path, error) { pt.Name = "/" + pt.Name } pt.Name = strings.TrimPrefix(pt.Name, i.Dir) + return pt, nil } diff --git a/pkg.go b/pkg.go index 31ce170..d79b58a 100644 --- a/pkg.go +++ b/pkg.go @@ -32,7 +32,7 @@ func (h Here) Package(p string) (Info, error) { }) if err != nil { - return i, err + return i, fmt.Errorf("here.Package: %s: %w", p, err) } h.cache(i.Dir, func(p string) (Info, error) {