Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

../gopkg.in/go-playground/validator.v9/translations/ja/ja.go:13:2: cannot find package "github.com/go-playground/validator/v10" in any of: #546

Open
leica19 opened this issue Nov 19, 2019 · 14 comments
Assignees

Comments

@leica19
Copy link

leica19 commented Nov 19, 2019

Package version eg. v8, v9:

v9

Issue, Question or Enhancement:

how should I fix the error as in the title.

Code sample, to showcase or reproduce:

the app container logs below:

hoge-api  | ../gopkg.in/go-playground/validator.v9/translations/ja/ja.go:13:2: cannot find package "github.com/go-playground/validator/v10" in any of:
hoge-api  | 	/usr/local/go/src/github.com/go-playground/validator/v10 (from $GOROOT)
hoge-api  | 	/go/src/github.com/go-playground/validator/v10 (from $GOPATH)

when I attach the container and check the import sentences, it, indeed, imports "github.com/go-playground/validator/v10"

docker exec -it hoge-api head -n 20 /go/src/gopkg.in/go-playground/validator.v9/translations/ja/ja.go
package ja

import (
	"fmt"
	"log"
	"reflect"
	"strconv"
	"strings"
	"time"

	"github.com/go-playground/locales"
	ut "github.com/go-playground/universal-translator"
	"github.com/go-playground/validator/v10" // **here**

// RegisterDefaultTranslations registers a set of default translations
// for all built in tag's in validator; you may add your own as desired.
func RegisterDefaultTranslations(v *validator.Validate, trans ut.Translator) (err error) {

	translations := []struct {
@leica19
Copy link
Author

leica19 commented Nov 20, 2019

the run command I use in Dockerfile is below.

RUN go get -u gopkg.in/go-playground/validator.v9

@kharbiyanov
Copy link

hello. i have error in v10 vendor/utils/validator.go:27:52: cannot use Validate (type *"gopkg.in/go-playground/validator.v10".Validate) as type *"github.com/go-playground/validator".Validate in argument to "gopkg.in/go-playground/validator.v10/translations/en".RegisterDefaultTranslations

@deankarn
Copy link
Contributor

see #549 , think it's fixed on v9.30.2

@leica19
Copy link
Author

leica19 commented Nov 26, 2019

@deankarn
thank you so much. i'll try the new ver.

@deankarn
Copy link
Contributor

Please let me know if it’s all good now :)

@lethe3000
Copy link

still failing for me when validator is depended by gin

$ 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/Cellar/go/1.13.3/libexec/src/github.com/go-playground/validator/v10 (from $GOROOT)
        /Users/lethe/work/go/src/github.com/go-playground/validator/v10 (from $GOPATH)

@aioloszcy
Copy link

still failing for me when validator is depended by gin

$ 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/Cellar/go/1.13.3/libexec/src/github.com/go-playground/validator/v10 (from $GOROOT)
        /Users/lethe/work/go/src/github.com/go-playground/validator/v10 (from $GOPATH)

i got the same error
MacBook-Pro-3:go-playground zhuchuanyun$ 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:
/Volumes/NVME/usr/go/src/github.com/go-playground/validator/v10 (from $GOROOT)
/Volumes/NVME/usr/golang/src/github.com/go-playground/validator/v10 (from $GOPATH)

@piyushgupta27
Copy link

Any updates on this? This is a blocker because the docker builds are failing for us. Please help

@laoluotuo
Copy link

laoluotuo commented Dec 6, 2019

Any updates on this? This is a blocker because the docker builds are failing for us. Please help

I

still failing for me when validator is depended by gin

$ 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/Cellar/go/1.13.3/libexec/src/github.com/go-playground/validator/v10 (from $GOROOT)
        /Users/lethe/work/go/src/github.com/go-playground/validator/v10 (from $GOPATH)

i got the same error
MacBook-Pro-3:go-playground zhuchuanyun$ 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:
/Volumes/NVME/usr/go/src/github.com/go-playground/validator/v10 (from $GOROOT)
/Volumes/NVME/usr/golang/src/github.com/go-playground/validator/v10 (from $GOPATH)

There's something wrong with this library , if you "go get" or "govendor fetch" the latest version, there is still not a folder named "v10" or it is empty, so you have to do it manually:
$go get "gopkg.in/go-playground/validator.v10"
$mkdir -p $GOPATH/src/vendor/github.com/go-playground/validator/v10
$cp -rf $GOPATH/src/gopkg.in/go-playground/validator.v10/* $GOPATH/src/vendor/github.com/go-playground/validator/v10

@deankarn
Copy link
Contributor

deankarn commented Dec 6, 2019

@laoluotuo are you using go modules?
I ask because you mentioned using govendor.

The path with the v10 suffix won’t work with pre-existing tooling prior to go modules, but you should be able to drop the suffix if that’s the case.

@deankarn deankarn self-assigned this Dec 9, 2019
@laoluotuo
Copy link

@laoluotuo are you using go modules?
I ask because you mentioned using govendor.

The path with the v10 suffix won’t work with pre-existing tooling prior to go modules, but you should be able to drop the suffix if that’s the case.

I'm only using govendor

@kyopark2014
Copy link

Try these.
It worked in my case.

$ sudo add-apt-repository ppa:longsleep/golang-backports
$ sudo apt-get update
$ sudo apt-get install golang-go

@xis
Copy link

xis commented Dec 19, 2019

still getting same error

@deankarn
Copy link
Contributor

Hey all, I've had to explain this a few times, go modules has fractured the community pretty hard.

gopkg.in/go-playground/validator.v10 is NOT a valid import path❗️

v10 was the changeover from using gopkg.in to go modules for versioning. If you are not on go modules, stick with gopkg.in/go-playground/validator.v9, if you're using go modules, update to using github.com/go-playground/validator/v10.

I encourage everyone to update to using Go Modules to help resolve the bad state the community is in where much of the old versioning tooling is not compatible with the new Go Modules.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants