mwitkow / go-proto-validators

Generate message validators from .proto annotations.
Apache License 2.0
1.09k stars 164 forks source link

support go modules #81

Open kheraankit opened 4 years ago

kheraankit commented 4 years ago

We are running into following error when trying to configure.

can't load package: package github.com/protocolbuffers/protobuf: unknown import path "github.com/protocolbuffers/protobuf": cannot find module providing package github.com/protocolbuffers/protobuf

go list -f '{{ .Dir }}' -m github.com/protocolbuffers/protobuf
$GOPATH/pkg/mod/github.com/protocolbuffers/protobuf@v3.10.1+incompatible
kheraankit commented 4 years ago

Was able to go past errors, looks like have to add to proto_path and during import use relative path. Maybe add to documentation?

protoc --proto_path="./" --proto_path=`go list -f '{{ .Dir }}' -m github.com/mwitkow/go-proto-validators` --proto_path=`go list -f '{{ .Dir }}' -m github.com/protocolbuffers/protobuf` --govalidators_out=../.gen --go_out=plugins=grpc:../.gen *.proto

in your project .proto file doe import "validator.proto";

AlekSi commented 4 years ago

Why you use github.com/protocolbuffers/protobuf instead of github.com/golang/protobuf ?

HelloZouYou commented 4 years ago

hello,i tried it, but got code like

import (
    _ "."
    ...
)