validator: cannot find package "github.com/go-playground/validator/v10" in any of
Package version eg. v8, v9:
v10
Issue, Question or Enhancement:
go get github.com/go-playground/validator/v10
give following error
package github.com/go-playground/validator/v10: cannot find package "github.com/go-playground/validator/v10" in any of:
/usr/local/go/src/github.com/go-playground/validator/v10 (from $GOROOT)
/go/src/github.com/go-playground/validator/v10 (from $GOPATH)
Code sample, to showcase or reproduce:
using golang docker latest
$ docker run -it --rm golang sh
$ go get github.com/go-playground/validator/v10
package github.com/go-playground/validator/v10: cannot find package "github.com/go-playground/validator/v10" in any of:
/usr/local/go/src/github.com/go-playground/validator/v10 (from $GOROOT)
/go/src/github.com/go-playground/validator/v10 (from $GOPATH)
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 17
- Comments: 20 (2 by maintainers)
Hi folks, I stumbled with this issue. In my case this is used by another library(gin) but I noticed there is no v10 directory, and since I read this v10 was used for a transition but not longer exists, maybe symlinking to the same project work, and in fact it worked.
And yes, I know it’s too hacky and I don’t really know the side effects.
I did:
I just initialised my project with
go mod initcommand. Your go get command working after that.Had the same problem with golang:1.14.2-alpine3.11, added
to the dockerfile fixed the issue.
@Higan as mentioned in the EDIT for me updating my
golangversion did the trick … it’s really a pity that this module topic broke oldergolangprojects (due to the fact that earlier versions of the language simply didn’t allow to explicitly specify certain versions as dependencies).these are the steps i’m using in my dockerfile:
The reason that’s this isn’t working is really that go modules is a breaking change to the ecosystem and isn’t compatible with previous tooling.
unfortunately there’s not much I can do about that from this package. If gin changed the import path back to github.com/go-playground/validator and then changed the go mod file to import by tag instead eg. Go get github.com/go-playground/validator@v10.x.x that may be an option but for non go modules projects you’d lose versioning of this package and always be pulling the latest master.
The unfortunate reality is if you want to use a package like gin that has converted to using go modules one should really update their program to use go modules. The alternative is to keep using and older version of gin using some other dependency management.
To solve this I recommend:
Please let me know that this helps.
having the same problem when trying to run
go get -v github.com/gin-gonic/ginsince this is the default validator … running it in docker > fetching fordebian:stretchEDIT: was trying to update packages for an older project where i fixed the golang version to 1.10. updating to 1.11 seems to resolve this issue in my case (but lets see what else breaks)