From 6296cc1e4d4fa79aecace752188eb0ce7eca98cc Mon Sep 17 00:00:00 2001 From: WangGuan Date: Fri, 1 Apr 2022 22:37:47 +0800 Subject: [PATCH 1/4] Use go mod and update packages --- go.mod | 20 ++ go.sum | 38 ++++ proto/spec.pb.go | 305 -------------------------- proto/validator.pb.go | 201 +++++++++++++++++ proto/{spec.proto => validator.proto} | 0 5 files changed, 259 insertions(+), 305 deletions(-) create mode 100644 go.mod create mode 100644 go.sum delete mode 100644 proto/spec.pb.go create mode 100644 proto/validator.pb.go rename proto/{spec.proto => validator.proto} (100%) diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..ea4fc36 --- /dev/null +++ b/go.mod @@ -0,0 +1,20 @@ +module github.com/theplant/validator + +go 1.17 + +require ( + github.com/go-playground/validator v9.31.0+incompatible + github.com/golang/protobuf v1.5.2 + github.com/pkg/errors v0.9.1 + github.com/theplant/testingutils v0.0.0-20220314083015-b74d1aa8ac8a + google.golang.org/protobuf v1.28.0 +) + +require ( + github.com/davecgh/go-spew v1.1.1 // indirect + github.com/go-playground/locales v0.14.0 // indirect + github.com/go-playground/universal-translator v0.18.0 // indirect + github.com/leodido/go-urn v1.2.1 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect + gopkg.in/go-playground/assert.v1 v1.2.1 // indirect +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..22174ba --- /dev/null +++ b/go.sum @@ -0,0 +1,38 @@ +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/go-playground/locales v0.14.0 h1:u50s323jtVGugKlcYeyzC0etD1HifMjqmJqb8WugfUU= +github.com/go-playground/locales v0.14.0/go.mod h1:sawfccIbzZTqEDETgFXqTho0QybSa7l++s0DH+LDiLs= +github.com/go-playground/universal-translator v0.18.0 h1:82dyy6p4OuJq4/CByFNOn/jYrnRPArHwAcmLoJZxyho= +github.com/go-playground/universal-translator v0.18.0/go.mod h1:UvRDBj+xPUEGrFYl+lu/H90nyDXpg0fqeB/AQUGNTVA= +github.com/go-playground/validator v9.31.0+incompatible h1:UA72EPEogEnq76ehGdEDp4Mit+3FDh548oRqwVgNsHA= +github.com/go-playground/validator v9.31.0+incompatible/go.mod h1:yrEkQXlcI+PugkyDjY2bRrL/UBU4f3rvrgkN3V8JEig= +github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= +github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= +github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU= +github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/leodido/go-urn v1.2.1 h1:BqpAaACuzVSgi/VLzGZIobT2z4v53pjosyNd9Yv6n/w= +github.com/leodido/go-urn v1.2.1/go.mod h1:zt4jvISO2HfUBqxjfIshjdMTYS56ZS/qv49ictyFfxY= +github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= +github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0= +github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/theplant/testingutils v0.0.0-20220314083015-b74d1aa8ac8a h1:dF00sJtP57ZEVpkR5Wu0dtpz9Iw94xO6XBHUwTJr0hQ= +github.com/theplant/testingutils v0.0.0-20220314083015-b74d1aa8ac8a/go.mod h1:6qsvMzRXPoK9mAC1CV5Ggw8m/EzzO+TI3HsE1IX8BaA= +golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= +google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= +google.golang.org/protobuf v1.28.0 h1:w43yiav+6bVFTBQFZX0r7ipe9JQ1QsbMgHwbBziscLw= +google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/go-playground/assert.v1 v1.2.1 h1:xoYuJVE7KT85PYWrN730RguIQO0ePzVRfFMXadIrXTM= +gopkg.in/go-playground/assert.v1 v1.2.1/go.mod h1:9RXL0bg/zibRAgZUYszZSwO/z8Y/a8bDuhia5mkpMnE= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/proto/spec.pb.go b/proto/spec.pb.go deleted file mode 100644 index 4e28429..0000000 --- a/proto/spec.pb.go +++ /dev/null @@ -1,305 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.25.0-devel -// protoc v3.12.3 -// source: spec.proto - -package proto - -import ( - proto "github.com/golang/protobuf/proto" - any "github.com/golang/protobuf/ptypes/any" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" - sync "sync" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -// This is a compile-time assertion that a sufficiently up-to-date version -// of the legacy proto package is being used. -const _ = proto.ProtoPackageIsVersion4 - -type ValidationError struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Code string `protobuf:"bytes,1,opt,name=code,proto3" json:"code,omitempty"` - Msg string `protobuf:"bytes,2,opt,name=msg,proto3" json:"msg,omitempty"` - // default_view_msg is the default display message in view(web/app) when an error occurs. - DefaultViewMsg string `protobuf:"bytes,4,opt,name=default_view_msg,json=defaultViewMsg,proto3" json:"default_view_msg,omitempty"` - // Describes all violations in a client request. - FieldViolations []*ValidationError_FieldViolation `protobuf:"bytes,3,rep,name=field_violations,json=fieldViolations,proto3" json:"field_violations,omitempty"` -} - -func (x *ValidationError) Reset() { - *x = ValidationError{} - if protoimpl.UnsafeEnabled { - mi := &file_spec_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ValidationError) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ValidationError) ProtoMessage() {} - -func (x *ValidationError) ProtoReflect() protoreflect.Message { - mi := &file_spec_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ValidationError.ProtoReflect.Descriptor instead. -func (*ValidationError) Descriptor() ([]byte, []int) { - return file_spec_proto_rawDescGZIP(), []int{0} -} - -func (x *ValidationError) GetCode() string { - if x != nil { - return x.Code - } - return "" -} - -func (x *ValidationError) GetMsg() string { - if x != nil { - return x.Msg - } - return "" -} - -func (x *ValidationError) GetDefaultViewMsg() string { - if x != nil { - return x.DefaultViewMsg - } - return "" -} - -func (x *ValidationError) GetFieldViolations() []*ValidationError_FieldViolation { - if x != nil { - return x.FieldViolations - } - return nil -} - -// A message type used to describe a single bad request field. -type ValidationError_FieldViolation struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // A path leading to a field in the request body. The value will be a - // sequence of dot-separated identifiers that identify a protocol buffer - // field. E.g., "field_violations.field" would identify this field. - Field string `protobuf:"bytes,1,opt,name=field,proto3" json:"field,omitempty"` - Code string `protobuf:"bytes,2,opt,name=code,proto3" json:"code,omitempty"` - Param string `protobuf:"bytes,3,opt,name=param,proto3" json:"param,omitempty"` - // A description of why the request element is bad. - Msg string `protobuf:"bytes,4,opt,name=msg,proto3" json:"msg,omitempty"` - // default_view_msg is the default display message in view(web/app) when an error occurs. - DefaultViewMsg string `protobuf:"bytes,6,opt,name=default_view_msg,json=defaultViewMsg,proto3" json:"default_view_msg,omitempty"` - // Extension. - Payload *any.Any `protobuf:"bytes,5,opt,name=payload,proto3" json:"payload,omitempty"` -} - -func (x *ValidationError_FieldViolation) Reset() { - *x = ValidationError_FieldViolation{} - if protoimpl.UnsafeEnabled { - mi := &file_spec_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ValidationError_FieldViolation) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ValidationError_FieldViolation) ProtoMessage() {} - -func (x *ValidationError_FieldViolation) ProtoReflect() protoreflect.Message { - mi := &file_spec_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ValidationError_FieldViolation.ProtoReflect.Descriptor instead. -func (*ValidationError_FieldViolation) Descriptor() ([]byte, []int) { - return file_spec_proto_rawDescGZIP(), []int{0, 0} -} - -func (x *ValidationError_FieldViolation) GetField() string { - if x != nil { - return x.Field - } - return "" -} - -func (x *ValidationError_FieldViolation) GetCode() string { - if x != nil { - return x.Code - } - return "" -} - -func (x *ValidationError_FieldViolation) GetParam() string { - if x != nil { - return x.Param - } - return "" -} - -func (x *ValidationError_FieldViolation) GetMsg() string { - if x != nil { - return x.Msg - } - return "" -} - -func (x *ValidationError_FieldViolation) GetDefaultViewMsg() string { - if x != nil { - return x.DefaultViewMsg - } - return "" -} - -func (x *ValidationError_FieldViolation) GetPayload() *any.Any { - if x != nil { - return x.Payload - } - return nil -} - -var File_spec_proto protoreflect.FileDescriptor - -var file_spec_proto_rawDesc = []byte{ - 0x0a, 0x0a, 0x73, 0x70, 0x65, 0x63, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x05, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x1a, 0x19, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x61, 0x6e, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xf2, - 0x02, 0x0a, 0x0f, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x45, 0x72, 0x72, - 0x6f, 0x72, 0x12, 0x12, 0x0a, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x6d, 0x73, 0x67, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x03, 0x6d, 0x73, 0x67, 0x12, 0x28, 0x0a, 0x10, 0x64, 0x65, 0x66, 0x61, - 0x75, 0x6c, 0x74, 0x5f, 0x76, 0x69, 0x65, 0x77, 0x5f, 0x6d, 0x73, 0x67, 0x18, 0x04, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x0e, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x56, 0x69, 0x65, 0x77, 0x4d, - 0x73, 0x67, 0x12, 0x50, 0x0a, 0x10, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x5f, 0x76, 0x69, 0x6f, 0x6c, - 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x45, - 0x72, 0x72, 0x6f, 0x72, 0x2e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x56, 0x69, 0x6f, 0x6c, 0x61, 0x74, - 0x69, 0x6f, 0x6e, 0x52, 0x0f, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x56, 0x69, 0x6f, 0x6c, 0x61, 0x74, - 0x69, 0x6f, 0x6e, 0x73, 0x1a, 0xbc, 0x01, 0x0a, 0x0e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x56, 0x69, - 0x6f, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x14, 0x0a, 0x05, 0x66, 0x69, 0x65, 0x6c, 0x64, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x12, 0x12, 0x0a, - 0x04, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x63, 0x6f, 0x64, - 0x65, 0x12, 0x14, 0x0a, 0x05, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x05, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x12, 0x10, 0x0a, 0x03, 0x6d, 0x73, 0x67, 0x18, 0x04, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6d, 0x73, 0x67, 0x12, 0x28, 0x0a, 0x10, 0x64, 0x65, 0x66, - 0x61, 0x75, 0x6c, 0x74, 0x5f, 0x76, 0x69, 0x65, 0x77, 0x5f, 0x6d, 0x73, 0x67, 0x18, 0x06, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x0e, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x56, 0x69, 0x65, 0x77, - 0x4d, 0x73, 0x67, 0x12, 0x2e, 0x0a, 0x07, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x18, 0x05, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, 0x52, 0x07, 0x70, 0x61, 0x79, 0x6c, - 0x6f, 0x61, 0x64, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} - -var ( - file_spec_proto_rawDescOnce sync.Once - file_spec_proto_rawDescData = file_spec_proto_rawDesc -) - -func file_spec_proto_rawDescGZIP() []byte { - file_spec_proto_rawDescOnce.Do(func() { - file_spec_proto_rawDescData = protoimpl.X.CompressGZIP(file_spec_proto_rawDescData) - }) - return file_spec_proto_rawDescData -} - -var file_spec_proto_msgTypes = make([]protoimpl.MessageInfo, 2) -var file_spec_proto_goTypes = []interface{}{ - (*ValidationError)(nil), // 0: proto.ValidationError - (*ValidationError_FieldViolation)(nil), // 1: proto.ValidationError.FieldViolation - (*any.Any)(nil), // 2: google.protobuf.Any -} -var file_spec_proto_depIdxs = []int32{ - 1, // 0: proto.ValidationError.field_violations:type_name -> proto.ValidationError.FieldViolation - 2, // 1: proto.ValidationError.FieldViolation.payload:type_name -> google.protobuf.Any - 2, // [2:2] is the sub-list for method output_type - 2, // [2:2] is the sub-list for method input_type - 2, // [2:2] is the sub-list for extension type_name - 2, // [2:2] is the sub-list for extension extendee - 0, // [0:2] is the sub-list for field type_name -} - -func init() { file_spec_proto_init() } -func file_spec_proto_init() { - if File_spec_proto != nil { - return - } - if !protoimpl.UnsafeEnabled { - file_spec_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ValidationError); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_spec_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ValidationError_FieldViolation); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_spec_proto_rawDesc, - NumEnums: 0, - NumMessages: 2, - NumExtensions: 0, - NumServices: 0, - }, - GoTypes: file_spec_proto_goTypes, - DependencyIndexes: file_spec_proto_depIdxs, - MessageInfos: file_spec_proto_msgTypes, - }.Build() - File_spec_proto = out.File - file_spec_proto_rawDesc = nil - file_spec_proto_goTypes = nil - file_spec_proto_depIdxs = nil -} diff --git a/proto/validator.pb.go b/proto/validator.pb.go new file mode 100644 index 0000000..d3c2f4e --- /dev/null +++ b/proto/validator.pb.go @@ -0,0 +1,201 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// source: validator.proto + +package proto + +import ( + fmt "fmt" + proto "github.com/golang/protobuf/proto" + anypb "google.golang.org/protobuf/types/known/anypb" + math "math" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package + +type ValidationError struct { + Code string `protobuf:"bytes,1,opt,name=code,proto3" json:"code,omitempty"` + Msg string `protobuf:"bytes,2,opt,name=msg,proto3" json:"msg,omitempty"` + // default_view_msg is the default display message in view(web/app) when an error occurs. + DefaultViewMsg string `protobuf:"bytes,4,opt,name=default_view_msg,json=defaultViewMsg,proto3" json:"default_view_msg,omitempty"` + // Describes all violations in a client request. + FieldViolations []*ValidationError_FieldViolation `protobuf:"bytes,3,rep,name=field_violations,json=fieldViolations,proto3" json:"field_violations,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *ValidationError) Reset() { *m = ValidationError{} } +func (m *ValidationError) String() string { return proto.CompactTextString(m) } +func (*ValidationError) ProtoMessage() {} +func (*ValidationError) Descriptor() ([]byte, []int) { + return fileDescriptor_bf1c6ec7c0d80dd5, []int{0} +} + +func (m *ValidationError) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_ValidationError.Unmarshal(m, b) +} +func (m *ValidationError) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_ValidationError.Marshal(b, m, deterministic) +} +func (m *ValidationError) XXX_Merge(src proto.Message) { + xxx_messageInfo_ValidationError.Merge(m, src) +} +func (m *ValidationError) XXX_Size() int { + return xxx_messageInfo_ValidationError.Size(m) +} +func (m *ValidationError) XXX_DiscardUnknown() { + xxx_messageInfo_ValidationError.DiscardUnknown(m) +} + +var xxx_messageInfo_ValidationError proto.InternalMessageInfo + +func (m *ValidationError) GetCode() string { + if m != nil { + return m.Code + } + return "" +} + +func (m *ValidationError) GetMsg() string { + if m != nil { + return m.Msg + } + return "" +} + +func (m *ValidationError) GetDefaultViewMsg() string { + if m != nil { + return m.DefaultViewMsg + } + return "" +} + +func (m *ValidationError) GetFieldViolations() []*ValidationError_FieldViolation { + if m != nil { + return m.FieldViolations + } + return nil +} + +// A message type used to describe a single bad request field. +type ValidationError_FieldViolation struct { + // A path leading to a field in the request body. The value will be a + // sequence of dot-separated identifiers that identify a protocol buffer + // field. E.g., "field_violations.field" would identify this field. + Field string `protobuf:"bytes,1,opt,name=field,proto3" json:"field,omitempty"` + Code string `protobuf:"bytes,2,opt,name=code,proto3" json:"code,omitempty"` + Param string `protobuf:"bytes,3,opt,name=param,proto3" json:"param,omitempty"` + // A description of why the request element is bad. + Msg string `protobuf:"bytes,4,opt,name=msg,proto3" json:"msg,omitempty"` + // default_view_msg is the default display message in view(web/app) when an error occurs. + DefaultViewMsg string `protobuf:"bytes,6,opt,name=default_view_msg,json=defaultViewMsg,proto3" json:"default_view_msg,omitempty"` + // Extension. + Payload *anypb.Any `protobuf:"bytes,5,opt,name=payload,proto3" json:"payload,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *ValidationError_FieldViolation) Reset() { *m = ValidationError_FieldViolation{} } +func (m *ValidationError_FieldViolation) String() string { return proto.CompactTextString(m) } +func (*ValidationError_FieldViolation) ProtoMessage() {} +func (*ValidationError_FieldViolation) Descriptor() ([]byte, []int) { + return fileDescriptor_bf1c6ec7c0d80dd5, []int{0, 0} +} + +func (m *ValidationError_FieldViolation) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_ValidationError_FieldViolation.Unmarshal(m, b) +} +func (m *ValidationError_FieldViolation) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_ValidationError_FieldViolation.Marshal(b, m, deterministic) +} +func (m *ValidationError_FieldViolation) XXX_Merge(src proto.Message) { + xxx_messageInfo_ValidationError_FieldViolation.Merge(m, src) +} +func (m *ValidationError_FieldViolation) XXX_Size() int { + return xxx_messageInfo_ValidationError_FieldViolation.Size(m) +} +func (m *ValidationError_FieldViolation) XXX_DiscardUnknown() { + xxx_messageInfo_ValidationError_FieldViolation.DiscardUnknown(m) +} + +var xxx_messageInfo_ValidationError_FieldViolation proto.InternalMessageInfo + +func (m *ValidationError_FieldViolation) GetField() string { + if m != nil { + return m.Field + } + return "" +} + +func (m *ValidationError_FieldViolation) GetCode() string { + if m != nil { + return m.Code + } + return "" +} + +func (m *ValidationError_FieldViolation) GetParam() string { + if m != nil { + return m.Param + } + return "" +} + +func (m *ValidationError_FieldViolation) GetMsg() string { + if m != nil { + return m.Msg + } + return "" +} + +func (m *ValidationError_FieldViolation) GetDefaultViewMsg() string { + if m != nil { + return m.DefaultViewMsg + } + return "" +} + +func (m *ValidationError_FieldViolation) GetPayload() *anypb.Any { + if m != nil { + return m.Payload + } + return nil +} + +func init() { + proto.RegisterType((*ValidationError)(nil), "proto.ValidationError") + proto.RegisterType((*ValidationError_FieldViolation)(nil), "proto.ValidationError.FieldViolation") +} + +func init() { proto.RegisterFile("validator.proto", fileDescriptor_bf1c6ec7c0d80dd5) } + +var fileDescriptor_bf1c6ec7c0d80dd5 = []byte{ + // 264 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x90, 0xcd, 0x6a, 0x83, 0x40, + 0x14, 0x85, 0xf1, 0x2f, 0xa5, 0x37, 0x10, 0x65, 0x70, 0x31, 0xcd, 0x4a, 0x0a, 0x05, 0x57, 0x13, + 0x48, 0x9f, 0xa0, 0x8b, 0x76, 0x57, 0x28, 0x2e, 0xdc, 0xca, 0xa4, 0x33, 0xca, 0xc0, 0xc4, 0x2b, + 0xa3, 0x31, 0xf8, 0x6e, 0x7d, 0xaa, 0x3e, 0x41, 0x71, 0x26, 0x96, 0xa6, 0x94, 0xae, 0xbc, 0xe7, + 0xdc, 0x4f, 0xe6, 0x9c, 0x0b, 0xf1, 0xc8, 0xb5, 0x12, 0x7c, 0x40, 0xc3, 0x3a, 0x83, 0x03, 0x92, + 0xc8, 0x7e, 0xb6, 0x77, 0x0d, 0x62, 0xa3, 0xe5, 0xce, 0xaa, 0xc3, 0xa9, 0xde, 0xf1, 0x76, 0x72, + 0xc4, 0xfd, 0xa7, 0x0f, 0x71, 0xe9, 0xfe, 0x52, 0xd8, 0x3e, 0x1b, 0x83, 0x86, 0x10, 0x08, 0xdf, + 0x51, 0x48, 0xea, 0x65, 0x5e, 0x7e, 0x5b, 0xd8, 0x99, 0x24, 0x10, 0x1c, 0xfb, 0x86, 0xfa, 0xd6, + 0x9a, 0x47, 0x92, 0x43, 0x22, 0x64, 0xcd, 0x4f, 0x7a, 0xa8, 0x46, 0x25, 0xcf, 0xd5, 0xbc, 0x0e, + 0xed, 0x7a, 0x73, 0xf1, 0x4b, 0x25, 0xcf, 0xaf, 0x7d, 0x43, 0xde, 0x20, 0xa9, 0x95, 0xd4, 0xa2, + 0x1a, 0x15, 0x6a, 0xfb, 0x4e, 0x4f, 0x83, 0x2c, 0xc8, 0xd7, 0xfb, 0x07, 0x97, 0x82, 0xfd, 0x4a, + 0xc0, 0x5e, 0x66, 0xbc, 0x5c, 0xe8, 0x22, 0xae, 0xaf, 0x74, 0xbf, 0xfd, 0xf0, 0x60, 0x73, 0xcd, + 0x90, 0x14, 0x22, 0x4b, 0x5d, 0x52, 0x3b, 0xf1, 0x5d, 0xc5, 0xff, 0x51, 0x25, 0x85, 0xa8, 0xe3, + 0x86, 0x1f, 0x69, 0xe0, 0x48, 0x2b, 0x96, 0x82, 0xe1, 0xff, 0x05, 0x57, 0x7f, 0x16, 0x64, 0x70, + 0xd3, 0xf1, 0x49, 0x23, 0x17, 0x34, 0xca, 0xbc, 0x7c, 0xbd, 0x4f, 0x99, 0xbb, 0x38, 0x5b, 0x2e, + 0xce, 0x9e, 0xda, 0xa9, 0x58, 0xa0, 0xc3, 0xca, 0xda, 0x8f, 0x5f, 0x01, 0x00, 0x00, 0xff, 0xff, + 0x86, 0x98, 0x6b, 0x2a, 0xb0, 0x01, 0x00, 0x00, +} diff --git a/proto/spec.proto b/proto/validator.proto similarity index 100% rename from proto/spec.proto rename to proto/validator.proto From 01407c615058199fa156a0ce159eda2947db18dc Mon Sep 17 00:00:00 2001 From: WangGuan Date: Sat, 2 Apr 2022 00:33:01 +0800 Subject: [PATCH 2/4] Add go package option --- proto/validator.pb.go | 332 +++++++++++++++++++++++++++--------------- proto/validator.proto | 2 + 2 files changed, 218 insertions(+), 116 deletions(-) diff --git a/proto/validator.pb.go b/proto/validator.pb.go index d3c2f4e..65aeb86 100644 --- a/proto/validator.pb.go +++ b/proto/validator.pb.go @@ -1,93 +1,105 @@ // Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.28.0 +// protoc v3.17.3 // source: validator.proto -package proto +package __ import ( - fmt "fmt" - proto "github.com/golang/protobuf/proto" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" anypb "google.golang.org/protobuf/types/known/anypb" - math "math" + reflect "reflect" + sync "sync" ) -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) type ValidationError struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + Code string `protobuf:"bytes,1,opt,name=code,proto3" json:"code,omitempty"` Msg string `protobuf:"bytes,2,opt,name=msg,proto3" json:"msg,omitempty"` // default_view_msg is the default display message in view(web/app) when an error occurs. DefaultViewMsg string `protobuf:"bytes,4,opt,name=default_view_msg,json=defaultViewMsg,proto3" json:"default_view_msg,omitempty"` // Describes all violations in a client request. - FieldViolations []*ValidationError_FieldViolation `protobuf:"bytes,3,rep,name=field_violations,json=fieldViolations,proto3" json:"field_violations,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + FieldViolations []*ValidationError_FieldViolation `protobuf:"bytes,3,rep,name=field_violations,json=fieldViolations,proto3" json:"field_violations,omitempty"` } -func (m *ValidationError) Reset() { *m = ValidationError{} } -func (m *ValidationError) String() string { return proto.CompactTextString(m) } -func (*ValidationError) ProtoMessage() {} -func (*ValidationError) Descriptor() ([]byte, []int) { - return fileDescriptor_bf1c6ec7c0d80dd5, []int{0} +func (x *ValidationError) Reset() { + *x = ValidationError{} + if protoimpl.UnsafeEnabled { + mi := &file_validator_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } -func (m *ValidationError) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_ValidationError.Unmarshal(m, b) +func (x *ValidationError) String() string { + return protoimpl.X.MessageStringOf(x) } -func (m *ValidationError) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_ValidationError.Marshal(b, m, deterministic) -} -func (m *ValidationError) XXX_Merge(src proto.Message) { - xxx_messageInfo_ValidationError.Merge(m, src) -} -func (m *ValidationError) XXX_Size() int { - return xxx_messageInfo_ValidationError.Size(m) -} -func (m *ValidationError) XXX_DiscardUnknown() { - xxx_messageInfo_ValidationError.DiscardUnknown(m) + +func (*ValidationError) ProtoMessage() {} + +func (x *ValidationError) ProtoReflect() protoreflect.Message { + mi := &file_validator_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) } -var xxx_messageInfo_ValidationError proto.InternalMessageInfo +// Deprecated: Use ValidationError.ProtoReflect.Descriptor instead. +func (*ValidationError) Descriptor() ([]byte, []int) { + return file_validator_proto_rawDescGZIP(), []int{0} +} -func (m *ValidationError) GetCode() string { - if m != nil { - return m.Code +func (x *ValidationError) GetCode() string { + if x != nil { + return x.Code } return "" } -func (m *ValidationError) GetMsg() string { - if m != nil { - return m.Msg +func (x *ValidationError) GetMsg() string { + if x != nil { + return x.Msg } return "" } -func (m *ValidationError) GetDefaultViewMsg() string { - if m != nil { - return m.DefaultViewMsg +func (x *ValidationError) GetDefaultViewMsg() string { + if x != nil { + return x.DefaultViewMsg } return "" } -func (m *ValidationError) GetFieldViolations() []*ValidationError_FieldViolation { - if m != nil { - return m.FieldViolations +func (x *ValidationError) GetFieldViolations() []*ValidationError_FieldViolation { + if x != nil { + return x.FieldViolations } return nil } // A message type used to describe a single bad request field. type ValidationError_FieldViolation struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + // A path leading to a field in the request body. The value will be a // sequence of dot-separated identifiers that identify a protocol buffer // field. E.g., "field_violations.field" would identify this field. @@ -99,103 +111,191 @@ type ValidationError_FieldViolation struct { // default_view_msg is the default display message in view(web/app) when an error occurs. DefaultViewMsg string `protobuf:"bytes,6,opt,name=default_view_msg,json=defaultViewMsg,proto3" json:"default_view_msg,omitempty"` // Extension. - Payload *anypb.Any `protobuf:"bytes,5,opt,name=payload,proto3" json:"payload,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + Payload *anypb.Any `protobuf:"bytes,5,opt,name=payload,proto3" json:"payload,omitempty"` } -func (m *ValidationError_FieldViolation) Reset() { *m = ValidationError_FieldViolation{} } -func (m *ValidationError_FieldViolation) String() string { return proto.CompactTextString(m) } -func (*ValidationError_FieldViolation) ProtoMessage() {} -func (*ValidationError_FieldViolation) Descriptor() ([]byte, []int) { - return fileDescriptor_bf1c6ec7c0d80dd5, []int{0, 0} +func (x *ValidationError_FieldViolation) Reset() { + *x = ValidationError_FieldViolation{} + if protoimpl.UnsafeEnabled { + mi := &file_validator_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } -func (m *ValidationError_FieldViolation) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_ValidationError_FieldViolation.Unmarshal(m, b) -} -func (m *ValidationError_FieldViolation) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_ValidationError_FieldViolation.Marshal(b, m, deterministic) -} -func (m *ValidationError_FieldViolation) XXX_Merge(src proto.Message) { - xxx_messageInfo_ValidationError_FieldViolation.Merge(m, src) +func (x *ValidationError_FieldViolation) String() string { + return protoimpl.X.MessageStringOf(x) } -func (m *ValidationError_FieldViolation) XXX_Size() int { - return xxx_messageInfo_ValidationError_FieldViolation.Size(m) -} -func (m *ValidationError_FieldViolation) XXX_DiscardUnknown() { - xxx_messageInfo_ValidationError_FieldViolation.DiscardUnknown(m) + +func (*ValidationError_FieldViolation) ProtoMessage() {} + +func (x *ValidationError_FieldViolation) ProtoReflect() protoreflect.Message { + mi := &file_validator_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) } -var xxx_messageInfo_ValidationError_FieldViolation proto.InternalMessageInfo +// Deprecated: Use ValidationError_FieldViolation.ProtoReflect.Descriptor instead. +func (*ValidationError_FieldViolation) Descriptor() ([]byte, []int) { + return file_validator_proto_rawDescGZIP(), []int{0, 0} +} -func (m *ValidationError_FieldViolation) GetField() string { - if m != nil { - return m.Field +func (x *ValidationError_FieldViolation) GetField() string { + if x != nil { + return x.Field } return "" } -func (m *ValidationError_FieldViolation) GetCode() string { - if m != nil { - return m.Code +func (x *ValidationError_FieldViolation) GetCode() string { + if x != nil { + return x.Code } return "" } -func (m *ValidationError_FieldViolation) GetParam() string { - if m != nil { - return m.Param +func (x *ValidationError_FieldViolation) GetParam() string { + if x != nil { + return x.Param } return "" } -func (m *ValidationError_FieldViolation) GetMsg() string { - if m != nil { - return m.Msg +func (x *ValidationError_FieldViolation) GetMsg() string { + if x != nil { + return x.Msg } return "" } -func (m *ValidationError_FieldViolation) GetDefaultViewMsg() string { - if m != nil { - return m.DefaultViewMsg +func (x *ValidationError_FieldViolation) GetDefaultViewMsg() string { + if x != nil { + return x.DefaultViewMsg } return "" } -func (m *ValidationError_FieldViolation) GetPayload() *anypb.Any { - if m != nil { - return m.Payload +func (x *ValidationError_FieldViolation) GetPayload() *anypb.Any { + if x != nil { + return x.Payload } return nil } -func init() { - proto.RegisterType((*ValidationError)(nil), "proto.ValidationError") - proto.RegisterType((*ValidationError_FieldViolation)(nil), "proto.ValidationError.FieldViolation") -} - -func init() { proto.RegisterFile("validator.proto", fileDescriptor_bf1c6ec7c0d80dd5) } - -var fileDescriptor_bf1c6ec7c0d80dd5 = []byte{ - // 264 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x90, 0xcd, 0x6a, 0x83, 0x40, - 0x14, 0x85, 0xf1, 0x2f, 0xa5, 0x37, 0x10, 0x65, 0x70, 0x31, 0xcd, 0x4a, 0x0a, 0x05, 0x57, 0x13, - 0x48, 0x9f, 0xa0, 0x8b, 0x76, 0x57, 0x28, 0x2e, 0xdc, 0xca, 0xa4, 0x33, 0xca, 0xc0, 0xc4, 0x2b, - 0xa3, 0x31, 0xf8, 0x6e, 0x7d, 0xaa, 0x3e, 0x41, 0x71, 0x26, 0x96, 0xa6, 0x94, 0xae, 0xbc, 0xe7, - 0xdc, 0x4f, 0xe6, 0x9c, 0x0b, 0xf1, 0xc8, 0xb5, 0x12, 0x7c, 0x40, 0xc3, 0x3a, 0x83, 0x03, 0x92, - 0xc8, 0x7e, 0xb6, 0x77, 0x0d, 0x62, 0xa3, 0xe5, 0xce, 0xaa, 0xc3, 0xa9, 0xde, 0xf1, 0x76, 0x72, - 0xc4, 0xfd, 0xa7, 0x0f, 0x71, 0xe9, 0xfe, 0x52, 0xd8, 0x3e, 0x1b, 0x83, 0x86, 0x10, 0x08, 0xdf, - 0x51, 0x48, 0xea, 0x65, 0x5e, 0x7e, 0x5b, 0xd8, 0x99, 0x24, 0x10, 0x1c, 0xfb, 0x86, 0xfa, 0xd6, - 0x9a, 0x47, 0x92, 0x43, 0x22, 0x64, 0xcd, 0x4f, 0x7a, 0xa8, 0x46, 0x25, 0xcf, 0xd5, 0xbc, 0x0e, - 0xed, 0x7a, 0x73, 0xf1, 0x4b, 0x25, 0xcf, 0xaf, 0x7d, 0x43, 0xde, 0x20, 0xa9, 0x95, 0xd4, 0xa2, - 0x1a, 0x15, 0x6a, 0xfb, 0x4e, 0x4f, 0x83, 0x2c, 0xc8, 0xd7, 0xfb, 0x07, 0x97, 0x82, 0xfd, 0x4a, - 0xc0, 0x5e, 0x66, 0xbc, 0x5c, 0xe8, 0x22, 0xae, 0xaf, 0x74, 0xbf, 0xfd, 0xf0, 0x60, 0x73, 0xcd, - 0x90, 0x14, 0x22, 0x4b, 0x5d, 0x52, 0x3b, 0xf1, 0x5d, 0xc5, 0xff, 0x51, 0x25, 0x85, 0xa8, 0xe3, - 0x86, 0x1f, 0x69, 0xe0, 0x48, 0x2b, 0x96, 0x82, 0xe1, 0xff, 0x05, 0x57, 0x7f, 0x16, 0x64, 0x70, - 0xd3, 0xf1, 0x49, 0x23, 0x17, 0x34, 0xca, 0xbc, 0x7c, 0xbd, 0x4f, 0x99, 0xbb, 0x38, 0x5b, 0x2e, - 0xce, 0x9e, 0xda, 0xa9, 0x58, 0xa0, 0xc3, 0xca, 0xda, 0x8f, 0x5f, 0x01, 0x00, 0x00, 0xff, 0xff, - 0x86, 0x98, 0x6b, 0x2a, 0xb0, 0x01, 0x00, 0x00, +var File_validator_proto protoreflect.FileDescriptor + +var file_validator_proto_rawDesc = []byte{ + 0x0a, 0x0f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x12, 0x05, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x19, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, + 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x61, 0x6e, 0x79, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x22, 0xf2, 0x02, 0x0a, 0x0f, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x12, 0x12, 0x0a, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x6d, + 0x73, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6d, 0x73, 0x67, 0x12, 0x28, 0x0a, + 0x10, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x5f, 0x76, 0x69, 0x65, 0x77, 0x5f, 0x6d, 0x73, + 0x67, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, + 0x56, 0x69, 0x65, 0x77, 0x4d, 0x73, 0x67, 0x12, 0x50, 0x0a, 0x10, 0x66, 0x69, 0x65, 0x6c, 0x64, + 0x5f, 0x76, 0x69, 0x6f, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, + 0x0b, 0x32, 0x25, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x2e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x56, + 0x69, 0x6f, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0f, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x56, + 0x69, 0x6f, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x1a, 0xbc, 0x01, 0x0a, 0x0e, 0x46, 0x69, + 0x65, 0x6c, 0x64, 0x56, 0x69, 0x6f, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x14, 0x0a, 0x05, + 0x66, 0x69, 0x65, 0x6c, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x66, 0x69, 0x65, + 0x6c, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x18, + 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x12, 0x10, 0x0a, 0x03, + 0x6d, 0x73, 0x67, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6d, 0x73, 0x67, 0x12, 0x28, + 0x0a, 0x10, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x5f, 0x76, 0x69, 0x65, 0x77, 0x5f, 0x6d, + 0x73, 0x67, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, + 0x74, 0x56, 0x69, 0x65, 0x77, 0x4d, 0x73, 0x67, 0x12, 0x2e, 0x0a, 0x07, 0x70, 0x61, 0x79, 0x6c, + 0x6f, 0x61, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, + 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, 0x52, + 0x07, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x42, 0x04, 0x5a, 0x02, 0x2e, 0x2f, 0x62, 0x06, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_validator_proto_rawDescOnce sync.Once + file_validator_proto_rawDescData = file_validator_proto_rawDesc +) + +func file_validator_proto_rawDescGZIP() []byte { + file_validator_proto_rawDescOnce.Do(func() { + file_validator_proto_rawDescData = protoimpl.X.CompressGZIP(file_validator_proto_rawDescData) + }) + return file_validator_proto_rawDescData +} + +var file_validator_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_validator_proto_goTypes = []interface{}{ + (*ValidationError)(nil), // 0: proto.ValidationError + (*ValidationError_FieldViolation)(nil), // 1: proto.ValidationError.FieldViolation + (*anypb.Any)(nil), // 2: google.protobuf.Any +} +var file_validator_proto_depIdxs = []int32{ + 1, // 0: proto.ValidationError.field_violations:type_name -> proto.ValidationError.FieldViolation + 2, // 1: proto.ValidationError.FieldViolation.payload:type_name -> google.protobuf.Any + 2, // [2:2] is the sub-list for method output_type + 2, // [2:2] is the sub-list for method input_type + 2, // [2:2] is the sub-list for extension type_name + 2, // [2:2] is the sub-list for extension extendee + 0, // [0:2] is the sub-list for field type_name +} + +func init() { file_validator_proto_init() } +func file_validator_proto_init() { + if File_validator_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_validator_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ValidationError); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_validator_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ValidationError_FieldViolation); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_validator_proto_rawDesc, + NumEnums: 0, + NumMessages: 2, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_validator_proto_goTypes, + DependencyIndexes: file_validator_proto_depIdxs, + MessageInfos: file_validator_proto_msgTypes, + }.Build() + File_validator_proto = out.File + file_validator_proto_rawDesc = nil + file_validator_proto_goTypes = nil + file_validator_proto_depIdxs = nil } diff --git a/proto/validator.proto b/proto/validator.proto index 6951b6d..a3fffa6 100644 --- a/proto/validator.proto +++ b/proto/validator.proto @@ -4,6 +4,8 @@ package proto; import "google/protobuf/any.proto"; +option go_package = "./"; + message ValidationError { string code = 1; From 74b01be281337c9ecaf17bcbf5ee6e071024e588 Mon Sep 17 00:00:00 2001 From: WangGuan Date: Sat, 2 Apr 2022 00:34:49 +0800 Subject: [PATCH 3/4] Change package name --- proto/validator.pb.go | 6 +++--- proto/validator.proto | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/proto/validator.pb.go b/proto/validator.pb.go index 65aeb86..cc43d5c 100644 --- a/proto/validator.pb.go +++ b/proto/validator.pb.go @@ -4,7 +4,7 @@ // protoc v3.17.3 // source: validator.proto -package __ +package proto import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" @@ -217,8 +217,8 @@ var file_validator_proto_rawDesc = []byte{ 0x74, 0x56, 0x69, 0x65, 0x77, 0x4d, 0x73, 0x67, 0x12, 0x2e, 0x0a, 0x07, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, 0x52, - 0x07, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x42, 0x04, 0x5a, 0x02, 0x2e, 0x2f, 0x62, 0x06, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x07, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x42, 0x0a, 0x5a, 0x08, 0x2e, 0x2f, 0x3b, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/proto/validator.proto b/proto/validator.proto index a3fffa6..99f4722 100644 --- a/proto/validator.proto +++ b/proto/validator.proto @@ -4,7 +4,7 @@ package proto; import "google/protobuf/any.proto"; -option go_package = "./"; +option go_package = "./;proto"; message ValidationError { string code = 1; From 039dfcbfa6f64bfc06dede73a60a04065522f228 Mon Sep 17 00:00:00 2001 From: WangGuan Date: Sat, 2 Apr 2022 00:45:36 +0800 Subject: [PATCH 4/4] Change modd and pakage path --- modd.conf | 2 +- proto/validator.pb.go | 6 ++++-- proto/validator.proto | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/modd.conf b/modd.conf index be4dd37..95e1c96 100644 --- a/modd.conf +++ b/modd.conf @@ -1,7 +1,7 @@ proto/*.proto { prep: " for i in @mods; do - protoc --proto_path=${GOPATH}/src -I=$(dirname $i) --go_out=$(dirname $i) $i + protoc --proto_path=${GOPATH}/src -I=$(dirname $i) --go_out=${GOPATH}/src $i done " } diff --git a/proto/validator.pb.go b/proto/validator.pb.go index cc43d5c..ead5d26 100644 --- a/proto/validator.pb.go +++ b/proto/validator.pb.go @@ -217,8 +217,10 @@ var file_validator_proto_rawDesc = []byte{ 0x74, 0x56, 0x69, 0x65, 0x77, 0x4d, 0x73, 0x67, 0x12, 0x2e, 0x0a, 0x07, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, 0x52, - 0x07, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x42, 0x0a, 0x5a, 0x08, 0x2e, 0x2f, 0x3b, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x07, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x42, 0x2b, 0x5a, 0x29, 0x67, 0x69, 0x74, 0x68, + 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x74, 0x68, 0x65, 0x70, 0x6c, 0x61, 0x6e, 0x74, 0x2f, + 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x3b, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/proto/validator.proto b/proto/validator.proto index 99f4722..ac0aaa5 100644 --- a/proto/validator.proto +++ b/proto/validator.proto @@ -4,7 +4,7 @@ package proto; import "google/protobuf/any.proto"; -option go_package = "./;proto"; +option go_package = "github.com/theplant/validator/proto;proto"; message ValidationError { string code = 1;