h2non / gock

HTTP traffic mocking and testing made easy in Go ༼ʘ̚ل͜ʘ̚༽
https://pkg.go.dev/github.com/h2non/gock
MIT License
2.04k stars 106 forks source link

golangci-lint complains that no export data for "gopkg.in/h2non/gock.v1" #74

Open ghost opened 3 years ago

ghost commented 3 years ago

I copied the example from the README and tried to run golangci-lint on it. This is what I got:

√ ; lsd -l ook.go
.rw-rw-r-- yann yann 294 B Fri Sep 18 12:06:18 2020  ook.go
√ ; bat ook.go
       File: ook.go
   1   package main
   2
   3   import (
   4       "testing"
   5
   6       "gopkg.in/h2non/gock.v1"
   7   )
   8
   9   func TestFoo(t *testing.T) {
  10       defer gock.Off() // Flush pending mocks after test execution
  11
  12       gock.New("http://server.com").
  13           Get("/bar").
  14           Reply(200).
  15           JSON(map[string]string{"foo": "bar"})
  16
  17       // Your test code starts here...
  18   }
√ ; golangci-lint run ook.go
WARN [runner] Can't run linter goanalysis_metalinter: S1033: failed prerequisites: [(inspect@command-line-arguments, isgenerated@command-line-arguments): analysis skipped: errors in package: [/home/yann/tmp/ook.go:6:2: could not import gopkg.in/h2non/gock.v1 (ook.go:6:2: cannot find module providing package gopkg.in/h2non/gock.v1: working directory is not part of a module) /home/yann/tmp/ook.go:10:8: undeclared name: gock /home/yann/tmp/ook.go:12:2: undeclared name: gock /home/yann/tmp/ook.go:6:2: "gopkg.in/h2non/gock.v1" imported but not used]]
WARN [runner] Can't run linter unused: buildir: failed to load package : could not load export data: no export data for "gopkg.in/h2non/gock.v1"
ERRO Running error: buildir: failed to load package : could not load export data: no export data for "gopkg.in/h2non/gock.v1"
✗ 3 ;

Am I doing something wrong? If so, what? If not, is that a bug? …

h2non commented 3 years ago

Gotta migrate the package namespace to github.com in a future release.

ghost commented 3 years ago

Any update on this? It is blocking my CI. ☹

ghost commented 3 years ago

In the meantime, is there a way to make golangci-lint skip whatever file(s) use gock? I tried skip_file but that is no use since it does the linting, just skips the results. I tried //nolint but that seems to do nothing whatsoever.

h2non commented 3 years ago

Have no time nowadays. PR would be very welcome!

ghost commented 3 years ago

PR would be very welcome!

Let me see what I can do… I never did that before, so I'll have to read up on it all.

ghost commented 3 years ago

I tried this and I am still getting the same error. ☹