Open anthonyGuo opened 2 years ago
did you fix it ? I have the same issue
add this to go.sum
golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o=
fixed.
Seeing the same with aws sdk
Error parsing file error="/src/aws/ecs.go:9:2: could not import github.com/aws/aws-sdk-go/aws (invalid package name: \"\")" dry-run=false version=v2.14.1
go.sum:
github.com/aws/aws-sdk-go v1.44.126 h1:7HQJw2DNiwpxqMe2H7odGNT2rhO4SRrUe5/8dYXl0Jk=
github.com/aws/aws-sdk-go v1.44.126/go.mod h1:y4AeaBuwd2Lk+GepC1E9v0qOiTws0MIWAX4oIKwKHZo=
Any ideas how to fix this?
this is super frustrating, but is often solved by running a go mod tidy
go mod tidy
didn't work for me
have a try with go mod vendor
When running into this issue, please try using one of the binary distributions of mockery. A lot of these issues happen because of dependency issues in your go module, which is why go install
is not recommended.
I get this error with v2.26.1
using docker
version, I solved it by running the same command with the binary version after run go mod download
.
Running go get
on the module that, based on the error message, doesn't have a package name solved it for us.
Example: go get github.com/username/repo-name
If others could confirm if that solution above works, I'll add it to the FAQ ^
using -v "${GOPATH:-$HOME/go}/pkg/mod:/go/pkg/mod"
worked for me:
docker run --rm \
-v "${PWD}:/src" \
-v "${PWD}/scripts/mockery.yaml:/mockery.yaml" \
-v "${GOPATH:-$HOME/go}/pkg/mod:/go/pkg/mod" \
-w /src \
--user "$(id -u):$(id -g)" \
vektra/mockery \
--config="/mockery.yaml"
go get
and go mod tidy
did not work for me. I hit this when my effective $GOPATH
being used by my container had go 1.20 files in it and I was running in a go 1.21 context. (I'm running within a more complex docker abstraction). I was able to fix by passing in the proper versioned go path.
-v "${GOPATH:-$HOME/go}/pkg/mod:/go/pkg/mod"
thanks @j1cs
I found this question while googling this very error occurring in one of my org's private repos, and it turns out I was using the wrong Github secret key to give access to my other private repos within my GitHub Action. (lol feel like a dummy after wasting 30 mins trying different random solutions before realizing I had the wrong key the whole time)
@LandonTClipp seems like we can close the issue as #824 has been merged.
golang version go1.17.6 linux/amd64 mockery dry-run=false version=v2.9.4
go.mod require golang.org/x/sync v0.1.0
go mod download
log.go import ( "golang.org/x/sync/semaphore" )
mockery --all --inpackage --keeptree --output /root/baisheng/
27 Oct 22 07:32 UTC INF Starting mockery dry-run=false version=v2.9.4 27 Oct 22 07:32 UTC INF Walking dry-run=false version=v2.9.4 27 Oct 22 07:33 UTC ERR Error parsing file error="/root/baisheng/ git/ log.go:11:2: could not import golang.org/x/sync/semaphore (invalid package name: \" \")" dry-run=false version=v2.9.4