go-playground / validator

:100:Go Struct and Field validation, including Cross Field, Cross Struct, Map, Slice and Array diving
MIT License
16.61k stars 1.31k forks source link

../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 4 years ago

leica19 commented 4 years ago

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 commented 4 years ago

the run command I use in Dockerfile is below.

RUN go get -u gopkg.in/go-playground/validator.v9
kharbiyanov commented 4 years ago

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 commented 4 years ago

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

leica19 commented 4 years ago

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

deankarn commented 4 years ago

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

lethe3000 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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

laoluotuo commented 4 years ago

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 commented 4 years ago

@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.

laoluotuo commented 4 years ago

@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 commented 4 years ago

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 commented 4 years ago

still getting same error

deankarn commented 4 years ago

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.