go-proto-validators icon indicating copy to clipboard operation
go-proto-validators copied to clipboard

support go modules

Open kheraankit opened this issue 6 years ago • 3 comments

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/[email protected]+incompatible

kheraankit avatar Nov 13 '19 01:11 kheraankit

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";

kheraankit avatar Nov 13 '19 02:11 kheraankit

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

AlekSi avatar Jan 31 '20 06:01 AlekSi

hello,i tried it, but got code like

import (
    _ "."
    ...
)

HelloZouYou avatar May 19 '20 11:05 HelloZouYou