golang / mock

GoMock is a mocking framework for the Go programming language.
Apache License 2.0
9.28k stars 610 forks source link

mockgen err :Loading input failed: source directory is outside GOPATH #578

Closed franklihub closed 2 years ago

franklihub commented 3 years ago

go version go1.16.4 darwin/amd64 mockgen v1.6.0

go env

  GO111MODULE="on"
  GOARCH="amd64"
  GOBIN=""
  GOCACHE="/Users/xh-201120-3/Library/Caches/go-build"
  GOENV="/Users/xh-201120-3/Library/Application Support/go/env"
  GOEXE=""
  GOFLAGS=""
  GOHOSTARCH="amd64"
  GOHOSTOS="darwin"
  GOINSECURE=""
  GOMODCACHE="/Users/xh-201120-3/go/pkg/mod"
  GONOPROXY=""
  GONOSUMDB=""
  GOOS="darwin"
  GOPATH="/Users/xh-201120-3/go"
  GOPRIVATE=""
  GOPROXY="https://goproxy.io,direct"
  GOROOT="/usr/local/go"
  GOSUMDB="sum.golang.org"
  GOTMPDIR=""
  GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
  GOVCS=""
  GOVERSION="go1.16.4"
  GCCGO="gccgo"
  AR="ar"
  CC="clang"
  CXX="clang++"
  CGO_ENABLED="1"
  GOMOD="/dev/null"
  CGO_CFLAGS="-g -O2"
  CGO_CPPFLAGS=""
  CGO_CXXFLAGS="-g -O2"
  CGO_FFLAGS="-g -O2"
  CGO_LDFLAGS="-g -O2"
  PKG_CONFIG="pkg-config"

hm.go

package hellomock

type Talker interface {
  SayHello(word string)(response string)
}

mockgen -source=./hm.go

Loading input failed: source directory is outside GOPATH
anceneorg commented 2 years ago

try this command mockgen -source=hm.go

codyoss commented 2 years ago

Sorry for being slow to respond here but I think the comment above should fix this. Closing for now, feel free to reopen if you are still having issues.

mqzabin commented 2 years ago

try this command mockgen -source=hm.go

same here, removing ./ dont solve the issue