diff --git a/Makefile.buf b/Makefile.buf index dd695aab..f4dbc045 100644 --- a/Makefile.buf +++ b/Makefile.buf @@ -79,7 +79,7 @@ deps: $(BUF) .PHONY: local local: $(BUF) buf lint - buf breaking --against '.git#branch=master' + buf breaking --against '.git#branch=main' # https is what we run when testing in most CI providers. # This does breaking change detection against our remote HTTPS git repository. diff --git a/README.md b/README.md index 70cab282..ecee0fff 100644 --- a/README.md +++ b/README.md @@ -31,16 +31,22 @@ The protobuf compiler (protoc) is required. Get the golang protobuf code generator: +Before Go 1.17 ``` go get -u github.com/golang/protobuf/protoc-gen-go ``` +Starting from Go 1.17 +``` +go install github.com/golang/protobuf/protoc-gen-go +``` + #### 3. Vendored Dependencies -Retrieve and install the vendored dependencies for this project with [dep](https://github.com/golang/dep): +Retrieve and install the vendored dependencies for this project with go mod: ``` -dep ensure +go mod tidy ``` ### Installation @@ -115,6 +121,7 @@ to test the effects of changing the options and fields. Within the proto files, the following types are supported: - standard primitive types `uint32`, `uint64`, `int32`, `int64`, `float`, `double`, `bool`, `string` map to the same type at ORM level +- - [google wrapper types](https://github.com/golang/protobuf/blob/master/ptypes/wrappers/wrappers.proto) `google.protobuf.StringValue`, `.BoolValue`, `.UInt32Value`, `.FloatValue`, etc. map to pointers of the internal type at the ORM level, e.g. diff --git a/example/feature_demo/demo_multi_file_service_grpc.pb.go b/example/feature_demo/demo_multi_file_service_grpc.pb.go index 5aaa0a29..e76d4bc7 100644 --- a/example/feature_demo/demo_multi_file_service_grpc.pb.go +++ b/example/feature_demo/demo_multi_file_service_grpc.pb.go @@ -1,4 +1,8 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.2.0 +// - protoc v3.17.1 +// source: feature_demo/demo_multi_file_service.proto package example diff --git a/example/feature_demo/demo_service_grpc.pb.go b/example/feature_demo/demo_service_grpc.pb.go index c3934099..73e44af9 100644 --- a/example/feature_demo/demo_service_grpc.pb.go +++ b/example/feature_demo/demo_service_grpc.pb.go @@ -1,4 +1,8 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.2.0 +// - protoc v3.17.1 +// source: feature_demo/demo_service.proto package example diff --git a/example/feature_demo/demo_types.pb.go b/example/feature_demo/demo_types.pb.go index 44363026..9ac9b10d 100644 --- a/example/feature_demo/demo_types.pb.go +++ b/example/feature_demo/demo_types.pb.go @@ -114,6 +114,7 @@ type TestTypes struct { // The TimeOnly should act as uint32 value at business layer, but is automatically // converted to/from string at API and ORM level TimeOnly *types.TimeOnly `protobuf:"bytes,11,opt,name=time_only,json=timeOnly,proto3" json:"time_only,omitempty"` + Bigint *types.BigInt `protobuf:"bytes,12,opt,name=bigint,proto3" json:"bigint,omitempty"` } func (x *TestTypes) Reset() { @@ -225,6 +226,13 @@ func (x *TestTypes) GetTimeOnly() *types.TimeOnly { return nil } +func (x *TestTypes) GetBigint() *types.BigInt { + if x != nil { + return x.Bigint + } + return nil +} + // TypeWithID demonstrates some basic assocation behavior type TypeWithID struct { state protoimpl.MessageState @@ -1049,7 +1057,7 @@ var file_feature_demo_demo_types_proto_rawDesc = []byte{ 0x75, 0x73, 0x65, 0x72, 0x2f, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x22, 0x66, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x5f, 0x64, 0x65, 0x6d, 0x6f, 0x2f, 0x64, 0x65, 0x6d, 0x6f, 0x5f, 0x6d, 0x75, 0x6c, 0x74, 0x69, 0x5f, 0x66, 0x69, 0x6c, 0x65, 0x2e, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x22, 0xd1, 0x05, 0x0a, 0x09, 0x54, 0x65, 0x73, 0x74, 0x54, 0x79, 0x70, 0x65, + 0x6f, 0x74, 0x6f, 0x22, 0xfd, 0x05, 0x0a, 0x09, 0x54, 0x65, 0x73, 0x74, 0x54, 0x79, 0x70, 0x65, 0x73, 0x12, 0x2e, 0x0a, 0x0f, 0x61, 0x70, 0x69, 0x5f, 0x6f, 0x6e, 0x6c, 0x79, 0x5f, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x06, 0xba, 0xb9, 0x19, 0x02, 0x10, 0x01, 0x52, 0x0d, 0x61, 0x70, 0x69, 0x4f, 0x6e, 0x6c, 0x79, 0x53, 0x74, 0x72, 0x69, 0x6e, @@ -1085,146 +1093,148 @@ var file_feature_demo_demo_types_proto_rawDesc = []byte{ 0x69, 0x64, 0x12, 0x31, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x5f, 0x6f, 0x6e, 0x6c, 0x79, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x72, 0x6d, 0x2e, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x4f, 0x6e, 0x6c, 0x79, 0x52, 0x08, 0x74, 0x69, 0x6d, - 0x65, 0x4f, 0x6e, 0x6c, 0x79, 0x22, 0x28, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, - 0x0b, 0x0a, 0x07, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x08, 0x0a, 0x04, - 0x47, 0x4f, 0x4f, 0x44, 0x10, 0x01, 0x12, 0x07, 0x0a, 0x03, 0x42, 0x41, 0x44, 0x10, 0x02, 0x3a, - 0x66, 0xba, 0xb9, 0x19, 0x62, 0x08, 0x01, 0x12, 0x27, 0x0a, 0x0b, 0x53, 0x74, 0x72, 0x69, 0x6e, - 0x67, 0x41, 0x72, 0x72, 0x61, 0x79, 0x12, 0x05, 0x61, 0x72, 0x72, 0x61, 0x79, 0x22, 0x11, 0x67, - 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6c, 0x69, 0x62, 0x2f, 0x70, 0x71, - 0x12, 0x28, 0x0a, 0x0b, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x41, 0x72, 0x72, 0x61, 0x79, 0x12, - 0x06, 0x61, 0x72, 0x72, 0x61, 0x79, 0x32, 0x22, 0x11, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, - 0x63, 0x6f, 0x6d, 0x2f, 0x6c, 0x69, 0x62, 0x2f, 0x70, 0x71, 0x1a, 0x0b, 0x73, 0x6d, 0x6f, 0x72, - 0x67, 0x61, 0x73, 0x62, 0x6f, 0x72, 0x64, 0x22, 0xc8, 0x06, 0x0a, 0x0a, 0x54, 0x79, 0x70, 0x65, - 0x57, 0x69, 0x74, 0x68, 0x49, 0x44, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x0d, 0x52, 0x02, 0x69, 0x64, 0x12, 0x1f, 0x0a, 0x02, 0x69, 0x70, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x09, 0x42, 0x0f, 0xba, 0xb9, 0x19, 0x0b, 0x0a, 0x09, 0x0a, 0x07, 0x69, 0x70, 0x5f, 0x61, - 0x64, 0x64, 0x72, 0x52, 0x02, 0x69, 0x70, 0x12, 0x2a, 0x0a, 0x06, 0x74, 0x68, 0x69, 0x6e, 0x67, - 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, - 0x65, 0x2e, 0x54, 0x65, 0x73, 0x74, 0x54, 0x79, 0x70, 0x65, 0x73, 0x52, 0x06, 0x74, 0x68, 0x69, - 0x6e, 0x67, 0x73, 0x12, 0x3a, 0x0a, 0x0f, 0x61, 0x5f, 0x6e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x5f, - 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x65, - 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x54, 0x65, 0x73, 0x74, 0x54, 0x79, 0x70, 0x65, 0x73, - 0x52, 0x0d, 0x61, 0x4e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x12, - 0x2f, 0x0a, 0x05, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x11, - 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x49, 0x6e, 0x74, 0x50, 0x6f, 0x69, 0x6e, - 0x74, 0x42, 0x06, 0xba, 0xb9, 0x19, 0x02, 0x22, 0x00, 0x52, 0x05, 0x70, 0x6f, 0x69, 0x6e, 0x74, - 0x12, 0x26, 0x0a, 0x04, 0x75, 0x73, 0x65, 0x72, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0a, - 0x2e, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x42, 0x06, 0xba, 0xb9, 0x19, 0x02, - 0x22, 0x00, 0x52, 0x04, 0x75, 0x73, 0x65, 0x72, 0x12, 0x2f, 0x0a, 0x07, 0x61, 0x64, 0x64, 0x72, - 0x65, 0x73, 0x73, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x67, 0x6f, 0x72, 0x6d, - 0x2e, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x49, 0x6e, 0x65, 0x74, 0x56, 0x61, 0x6c, 0x75, 0x65, - 0x52, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x3a, 0x0a, 0x15, 0x6d, 0x75, 0x6c, - 0x74, 0x69, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x5f, 0x69, - 0x64, 0x73, 0x18, 0x08, 0x20, 0x03, 0x28, 0x0d, 0x42, 0x06, 0xba, 0xb9, 0x19, 0x02, 0x10, 0x01, - 0x52, 0x13, 0x6d, 0x75, 0x6c, 0x74, 0x69, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x54, 0x79, - 0x70, 0x65, 0x49, 0x64, 0x73, 0x12, 0x3d, 0x0a, 0x0f, 0x73, 0x79, 0x6e, 0x74, 0x68, 0x65, 0x74, - 0x69, 0x63, 0x5f, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x18, 0x09, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, - 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x41, 0x50, 0x49, 0x4f, 0x6e, 0x6c, 0x79, - 0x54, 0x79, 0x70, 0x65, 0x52, 0x0e, 0x73, 0x79, 0x6e, 0x74, 0x68, 0x65, 0x74, 0x69, 0x63, 0x46, - 0x69, 0x65, 0x6c, 0x64, 0x12, 0x2a, 0x0a, 0x08, 0x74, 0x61, 0x67, 0x5f, 0x74, 0x65, 0x73, 0x74, - 0x18, 0x0a, 0x20, 0x01, 0x28, 0x02, 0x42, 0x0f, 0xba, 0xb9, 0x19, 0x0b, 0x0a, 0x09, 0x12, 0x05, - 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x20, 0x06, 0x52, 0x07, 0x74, 0x61, 0x67, 0x54, 0x65, 0x73, 0x74, - 0x12, 0x2d, 0x0a, 0x0d, 0x74, 0x61, 0x67, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x5f, 0x74, 0x65, 0x73, - 0x74, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x09, 0x42, 0x09, 0xba, 0xb9, 0x19, 0x05, 0x0a, 0x03, 0x18, - 0x80, 0x04, 0x52, 0x0b, 0x74, 0x61, 0x67, 0x53, 0x69, 0x7a, 0x65, 0x54, 0x65, 0x73, 0x74, 0x12, - 0x3c, 0x0a, 0x0b, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x5f, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x18, 0x0c, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x6c, 0x6f, 0x61, 0x74, 0x56, 0x61, 0x6c, 0x75, - 0x65, 0x52, 0x0a, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x12, 0x3f, 0x0a, - 0x0c, 0x64, 0x6f, 0x75, 0x62, 0x6c, 0x65, 0x5f, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x18, 0x0d, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x44, 0x6f, 0x75, 0x62, 0x6c, 0x65, 0x56, 0x61, 0x6c, 0x75, - 0x65, 0x52, 0x0b, 0x64, 0x6f, 0x75, 0x62, 0x6c, 0x65, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x12, 0x31, - 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x5f, 0x6f, 0x6e, 0x6c, 0x79, 0x18, 0x0e, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x72, 0x6d, 0x2e, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x54, - 0x69, 0x6d, 0x65, 0x4f, 0x6e, 0x6c, 0x79, 0x52, 0x08, 0x74, 0x69, 0x6d, 0x65, 0x4f, 0x6e, 0x6c, - 0x79, 0x12, 0x39, 0x0a, 0x0a, 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x64, 0x5f, 0x61, 0x74, 0x18, - 0x0f, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, - 0x70, 0x52, 0x09, 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x64, 0x41, 0x74, 0x3a, 0x54, 0xba, 0xb9, - 0x19, 0x50, 0x08, 0x01, 0x12, 0x17, 0x0a, 0x05, 0x69, 0x6e, 0x74, 0x33, 0x32, 0x12, 0x0a, 0x73, - 0x65, 0x63, 0x72, 0x65, 0x74, 0x5f, 0x69, 0x6e, 0x74, 0x1a, 0x02, 0x70, 0x01, 0x12, 0x33, 0x0a, - 0x0c, 0x5b, 0x5d, 0x2a, 0x4a, 0x6f, 0x69, 0x6e, 0x54, 0x61, 0x62, 0x6c, 0x65, 0x12, 0x13, 0x6d, - 0x75, 0x6c, 0x74, 0x69, 0x5f, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x5f, 0x74, 0x79, 0x70, - 0x65, 0x73, 0x1a, 0x0e, 0x7a, 0x0c, 0x54, 0x79, 0x70, 0x65, 0x57, 0x69, 0x74, 0x68, 0x49, 0x44, - 0x49, 0x44, 0x22, 0x51, 0x0a, 0x16, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x61, 0x63, 0x63, 0x6f, 0x75, - 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, 0x57, 0x69, 0x74, 0x68, 0x49, 0x44, 0x12, 0x0e, 0x0a, 0x02, - 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x02, 0x69, 0x64, 0x12, 0x1d, 0x0a, 0x0a, - 0x73, 0x6f, 0x6d, 0x65, 0x5f, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x09, 0x73, 0x6f, 0x6d, 0x65, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x3a, 0x08, 0xba, 0xb9, 0x19, - 0x04, 0x08, 0x01, 0x20, 0x01, 0x22, 0x44, 0x0a, 0x19, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x61, 0x63, - 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, 0x57, 0x69, 0x74, 0x68, 0x6f, 0x75, 0x74, - 0x49, 0x44, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x6f, 0x6d, 0x65, 0x5f, 0x66, 0x69, 0x65, 0x6c, 0x64, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x6f, 0x6d, 0x65, 0x46, 0x69, 0x65, 0x6c, - 0x64, 0x3a, 0x08, 0xba, 0xb9, 0x19, 0x04, 0x08, 0x01, 0x20, 0x01, 0x22, 0x29, 0x0a, 0x0b, 0x41, - 0x50, 0x49, 0x4f, 0x6e, 0x6c, 0x79, 0x54, 0x79, 0x70, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x63, 0x6f, - 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x63, 0x6f, - 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0x22, 0x6e, 0x0a, 0x0f, 0x50, 0x72, 0x69, 0x6d, 0x61, 0x72, - 0x79, 0x55, 0x55, 0x49, 0x44, 0x54, 0x79, 0x70, 0x65, 0x12, 0x25, 0x0a, 0x02, 0x69, 0x64, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x67, 0x6f, 0x72, 0x6d, 0x2e, 0x74, 0x79, 0x70, - 0x65, 0x73, 0x2e, 0x55, 0x55, 0x49, 0x44, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x02, 0x69, 0x64, - 0x12, 0x2c, 0x0a, 0x05, 0x63, 0x68, 0x69, 0x6c, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, - 0x16, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x45, 0x78, 0x74, 0x65, 0x72, 0x6e, - 0x61, 0x6c, 0x43, 0x68, 0x69, 0x6c, 0x64, 0x52, 0x05, 0x63, 0x68, 0x69, 0x6c, 0x64, 0x3a, 0x06, - 0xba, 0xb9, 0x19, 0x02, 0x08, 0x01, 0x22, 0x59, 0x0a, 0x11, 0x50, 0x72, 0x69, 0x6d, 0x61, 0x72, - 0x79, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x54, 0x79, 0x70, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, - 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x2c, 0x0a, 0x05, 0x63, - 0x68, 0x69, 0x6c, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x65, 0x78, 0x61, - 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x45, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x43, 0x68, 0x69, - 0x6c, 0x64, 0x52, 0x05, 0x63, 0x68, 0x69, 0x6c, 0x64, 0x3a, 0x06, 0xba, 0xb9, 0x19, 0x02, 0x08, - 0x01, 0x22, 0x6a, 0x0a, 0x07, 0x54, 0x65, 0x73, 0x74, 0x54, 0x61, 0x67, 0x12, 0x0e, 0x0a, 0x02, - 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x47, 0x0a, 0x0c, - 0x74, 0x65, 0x73, 0x74, 0x54, 0x61, 0x67, 0x41, 0x73, 0x73, 0x6f, 0x63, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x54, 0x65, 0x73, - 0x74, 0x54, 0x61, 0x67, 0x41, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x42, - 0x06, 0xba, 0xb9, 0x19, 0x02, 0x1a, 0x00, 0x52, 0x0c, 0x74, 0x65, 0x73, 0x74, 0x54, 0x61, 0x67, - 0x41, 0x73, 0x73, 0x6f, 0x63, 0x3a, 0x06, 0xba, 0xb9, 0x19, 0x02, 0x08, 0x01, 0x22, 0x7a, 0x0a, - 0x17, 0x54, 0x65, 0x73, 0x74, 0x41, 0x73, 0x73, 0x6f, 0x63, 0x48, 0x61, 0x6e, 0x64, 0x6c, 0x65, - 0x72, 0x44, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, + 0x65, 0x4f, 0x6e, 0x6c, 0x79, 0x12, 0x2a, 0x0a, 0x06, 0x62, 0x69, 0x67, 0x69, 0x6e, 0x74, 0x18, + 0x0c, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x67, 0x6f, 0x72, 0x6d, 0x2e, 0x74, 0x79, 0x70, + 0x65, 0x73, 0x2e, 0x42, 0x69, 0x67, 0x49, 0x6e, 0x74, 0x52, 0x06, 0x62, 0x69, 0x67, 0x69, 0x6e, + 0x74, 0x22, 0x28, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x0b, 0x0a, 0x07, 0x55, + 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x08, 0x0a, 0x04, 0x47, 0x4f, 0x4f, 0x44, + 0x10, 0x01, 0x12, 0x07, 0x0a, 0x03, 0x42, 0x41, 0x44, 0x10, 0x02, 0x3a, 0x66, 0xba, 0xb9, 0x19, + 0x62, 0x08, 0x01, 0x12, 0x27, 0x0a, 0x0b, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x41, 0x72, 0x72, + 0x61, 0x79, 0x12, 0x05, 0x61, 0x72, 0x72, 0x61, 0x79, 0x22, 0x11, 0x67, 0x69, 0x74, 0x68, 0x75, + 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6c, 0x69, 0x62, 0x2f, 0x70, 0x71, 0x12, 0x28, 0x0a, 0x0b, + 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x41, 0x72, 0x72, 0x61, 0x79, 0x12, 0x06, 0x61, 0x72, 0x72, + 0x61, 0x79, 0x32, 0x22, 0x11, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, + 0x6c, 0x69, 0x62, 0x2f, 0x70, 0x71, 0x1a, 0x0b, 0x73, 0x6d, 0x6f, 0x72, 0x67, 0x61, 0x73, 0x62, + 0x6f, 0x72, 0x64, 0x22, 0xc8, 0x06, 0x0a, 0x0a, 0x54, 0x79, 0x70, 0x65, 0x57, 0x69, 0x74, 0x68, + 0x49, 0x44, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x02, + 0x69, 0x64, 0x12, 0x1f, 0x0a, 0x02, 0x69, 0x70, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x42, 0x0f, + 0xba, 0xb9, 0x19, 0x0b, 0x0a, 0x09, 0x0a, 0x07, 0x69, 0x70, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x52, + 0x02, 0x69, 0x70, 0x12, 0x2a, 0x0a, 0x06, 0x74, 0x68, 0x69, 0x6e, 0x67, 0x73, 0x18, 0x03, 0x20, + 0x03, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x54, 0x65, + 0x73, 0x74, 0x54, 0x79, 0x70, 0x65, 0x73, 0x52, 0x06, 0x74, 0x68, 0x69, 0x6e, 0x67, 0x73, 0x12, + 0x3a, 0x0a, 0x0f, 0x61, 0x5f, 0x6e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x5f, 0x6f, 0x62, 0x6a, 0x65, + 0x63, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, + 0x6c, 0x65, 0x2e, 0x54, 0x65, 0x73, 0x74, 0x54, 0x79, 0x70, 0x65, 0x73, 0x52, 0x0d, 0x61, 0x4e, + 0x65, 0x73, 0x74, 0x65, 0x64, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x12, 0x2f, 0x0a, 0x05, 0x70, + 0x6f, 0x69, 0x6e, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x65, 0x78, 0x61, + 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x49, 0x6e, 0x74, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x42, 0x06, 0xba, + 0xb9, 0x19, 0x02, 0x22, 0x00, 0x52, 0x05, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x12, 0x26, 0x0a, 0x04, + 0x75, 0x73, 0x65, 0x72, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0a, 0x2e, 0x75, 0x73, 0x65, + 0x72, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x42, 0x06, 0xba, 0xb9, 0x19, 0x02, 0x22, 0x00, 0x52, 0x04, + 0x75, 0x73, 0x65, 0x72, 0x12, 0x2f, 0x0a, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, + 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x67, 0x6f, 0x72, 0x6d, 0x2e, 0x74, 0x79, 0x70, + 0x65, 0x73, 0x2e, 0x49, 0x6e, 0x65, 0x74, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x07, 0x61, 0x64, + 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x3a, 0x0a, 0x15, 0x6d, 0x75, 0x6c, 0x74, 0x69, 0x61, 0x63, + 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x5f, 0x69, 0x64, 0x73, 0x18, 0x08, + 0x20, 0x03, 0x28, 0x0d, 0x42, 0x06, 0xba, 0xb9, 0x19, 0x02, 0x10, 0x01, 0x52, 0x13, 0x6d, 0x75, + 0x6c, 0x74, 0x69, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, 0x49, 0x64, + 0x73, 0x12, 0x3d, 0x0a, 0x0f, 0x73, 0x79, 0x6e, 0x74, 0x68, 0x65, 0x74, 0x69, 0x63, 0x5f, 0x66, + 0x69, 0x65, 0x6c, 0x64, 0x18, 0x09, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x65, 0x78, 0x61, + 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x41, 0x50, 0x49, 0x4f, 0x6e, 0x6c, 0x79, 0x54, 0x79, 0x70, 0x65, + 0x52, 0x0e, 0x73, 0x79, 0x6e, 0x74, 0x68, 0x65, 0x74, 0x69, 0x63, 0x46, 0x69, 0x65, 0x6c, 0x64, + 0x12, 0x2a, 0x0a, 0x08, 0x74, 0x61, 0x67, 0x5f, 0x74, 0x65, 0x73, 0x74, 0x18, 0x0a, 0x20, 0x01, + 0x28, 0x02, 0x42, 0x0f, 0xba, 0xb9, 0x19, 0x0b, 0x0a, 0x09, 0x12, 0x05, 0x66, 0x6c, 0x6f, 0x61, + 0x74, 0x20, 0x06, 0x52, 0x07, 0x74, 0x61, 0x67, 0x54, 0x65, 0x73, 0x74, 0x12, 0x2d, 0x0a, 0x0d, + 0x74, 0x61, 0x67, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x5f, 0x74, 0x65, 0x73, 0x74, 0x18, 0x0b, 0x20, + 0x01, 0x28, 0x09, 0x42, 0x09, 0xba, 0xb9, 0x19, 0x05, 0x0a, 0x03, 0x18, 0x80, 0x04, 0x52, 0x0b, + 0x74, 0x61, 0x67, 0x53, 0x69, 0x7a, 0x65, 0x54, 0x65, 0x73, 0x74, 0x12, 0x3c, 0x0a, 0x0b, 0x66, + 0x6c, 0x6f, 0x61, 0x74, 0x5f, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x1b, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, + 0x75, 0x66, 0x2e, 0x46, 0x6c, 0x6f, 0x61, 0x74, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x0a, 0x66, + 0x6c, 0x6f, 0x61, 0x74, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x12, 0x3f, 0x0a, 0x0c, 0x64, 0x6f, 0x75, + 0x62, 0x6c, 0x65, 0x5f, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x1c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, + 0x66, 0x2e, 0x44, 0x6f, 0x75, 0x62, 0x6c, 0x65, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x0b, 0x64, + 0x6f, 0x75, 0x62, 0x6c, 0x65, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x12, 0x31, 0x0a, 0x09, 0x74, 0x69, + 0x6d, 0x65, 0x5f, 0x6f, 0x6e, 0x6c, 0x79, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, + 0x67, 0x6f, 0x72, 0x6d, 0x2e, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x4f, + 0x6e, 0x6c, 0x79, 0x52, 0x08, 0x74, 0x69, 0x6d, 0x65, 0x4f, 0x6e, 0x6c, 0x79, 0x12, 0x39, 0x0a, + 0x0a, 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x64, 0x5f, 0x61, 0x74, 0x18, 0x0f, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x09, 0x64, + 0x65, 0x6c, 0x65, 0x74, 0x65, 0x64, 0x41, 0x74, 0x3a, 0x54, 0xba, 0xb9, 0x19, 0x50, 0x08, 0x01, + 0x12, 0x17, 0x0a, 0x05, 0x69, 0x6e, 0x74, 0x33, 0x32, 0x12, 0x0a, 0x73, 0x65, 0x63, 0x72, 0x65, + 0x74, 0x5f, 0x69, 0x6e, 0x74, 0x1a, 0x02, 0x70, 0x01, 0x12, 0x33, 0x0a, 0x0c, 0x5b, 0x5d, 0x2a, + 0x4a, 0x6f, 0x69, 0x6e, 0x54, 0x61, 0x62, 0x6c, 0x65, 0x12, 0x13, 0x6d, 0x75, 0x6c, 0x74, 0x69, + 0x5f, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x1a, 0x0e, + 0x7a, 0x0c, 0x54, 0x79, 0x70, 0x65, 0x57, 0x69, 0x74, 0x68, 0x49, 0x44, 0x49, 0x44, 0x22, 0x51, + 0x0a, 0x16, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x54, 0x79, + 0x70, 0x65, 0x57, 0x69, 0x74, 0x68, 0x49, 0x44, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x04, 0x52, 0x02, 0x69, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x6f, 0x6d, 0x65, + 0x5f, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x6f, + 0x6d, 0x65, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x3a, 0x08, 0xba, 0xb9, 0x19, 0x04, 0x08, 0x01, 0x20, + 0x01, 0x22, 0x44, 0x0a, 0x19, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, + 0x74, 0x54, 0x79, 0x70, 0x65, 0x57, 0x69, 0x74, 0x68, 0x6f, 0x75, 0x74, 0x49, 0x44, 0x12, 0x1d, + 0x0a, 0x0a, 0x73, 0x6f, 0x6d, 0x65, 0x5f, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x09, 0x73, 0x6f, 0x6d, 0x65, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x3a, 0x08, 0xba, + 0xb9, 0x19, 0x04, 0x08, 0x01, 0x20, 0x01, 0x22, 0x29, 0x0a, 0x0b, 0x41, 0x50, 0x49, 0x4f, 0x6e, + 0x6c, 0x79, 0x54, 0x79, 0x70, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, + 0x74, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, + 0x74, 0x73, 0x22, 0x6e, 0x0a, 0x0f, 0x50, 0x72, 0x69, 0x6d, 0x61, 0x72, 0x79, 0x55, 0x55, 0x49, + 0x44, 0x54, 0x79, 0x70, 0x65, 0x12, 0x25, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x15, 0x2e, 0x67, 0x6f, 0x72, 0x6d, 0x2e, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x55, + 0x55, 0x49, 0x44, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x02, 0x69, 0x64, 0x12, 0x2c, 0x0a, 0x05, + 0x63, 0x68, 0x69, 0x6c, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x65, 0x78, + 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x45, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x43, 0x68, + 0x69, 0x6c, 0x64, 0x52, 0x05, 0x63, 0x68, 0x69, 0x6c, 0x64, 0x3a, 0x06, 0xba, 0xb9, 0x19, 0x02, + 0x08, 0x01, 0x22, 0x59, 0x0a, 0x11, 0x50, 0x72, 0x69, 0x6d, 0x61, 0x72, 0x79, 0x53, 0x74, 0x72, + 0x69, 0x6e, 0x67, 0x54, 0x79, 0x70, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x2c, 0x0a, 0x05, 0x63, 0x68, 0x69, 0x6c, 0x64, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, + 0x2e, 0x45, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x43, 0x68, 0x69, 0x6c, 0x64, 0x52, 0x05, + 0x63, 0x68, 0x69, 0x6c, 0x64, 0x3a, 0x06, 0xba, 0xb9, 0x19, 0x02, 0x08, 0x01, 0x22, 0x6a, 0x0a, + 0x07, 0x54, 0x65, 0x73, 0x74, 0x54, 0x61, 0x67, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x47, 0x0a, 0x0c, 0x74, 0x65, 0x73, 0x74, - 0x54, 0x61, 0x67, 0x41, 0x73, 0x73, 0x6f, 0x63, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1b, + 0x54, 0x61, 0x67, 0x41, 0x73, 0x73, 0x6f, 0x63, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x54, 0x65, 0x73, 0x74, 0x54, 0x61, 0x67, 0x41, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x06, 0xba, 0xb9, 0x19, - 0x02, 0x2a, 0x00, 0x52, 0x0c, 0x74, 0x65, 0x73, 0x74, 0x54, 0x61, 0x67, 0x41, 0x73, 0x73, 0x6f, - 0x63, 0x3a, 0x06, 0xba, 0xb9, 0x19, 0x02, 0x08, 0x01, 0x22, 0x7c, 0x0a, 0x17, 0x54, 0x65, 0x73, - 0x74, 0x41, 0x73, 0x73, 0x6f, 0x63, 0x48, 0x61, 0x6e, 0x64, 0x6c, 0x65, 0x72, 0x52, 0x65, 0x70, - 0x6c, 0x61, 0x63, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x02, 0x69, 0x64, 0x12, 0x49, 0x0a, 0x0c, 0x74, 0x65, 0x73, 0x74, 0x54, 0x61, 0x67, 0x41, + 0x02, 0x1a, 0x00, 0x52, 0x0c, 0x74, 0x65, 0x73, 0x74, 0x54, 0x61, 0x67, 0x41, 0x73, 0x73, 0x6f, + 0x63, 0x3a, 0x06, 0xba, 0xb9, 0x19, 0x02, 0x08, 0x01, 0x22, 0x7a, 0x0a, 0x17, 0x54, 0x65, 0x73, + 0x74, 0x41, 0x73, 0x73, 0x6f, 0x63, 0x48, 0x61, 0x6e, 0x64, 0x6c, 0x65, 0x72, 0x44, 0x65, 0x66, + 0x61, 0x75, 0x6c, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x02, 0x69, 0x64, 0x12, 0x47, 0x0a, 0x0c, 0x74, 0x65, 0x73, 0x74, 0x54, 0x61, 0x67, 0x41, 0x73, 0x73, 0x6f, 0x63, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x54, 0x65, 0x73, 0x74, 0x54, 0x61, 0x67, 0x41, 0x73, 0x73, 0x6f, - 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x08, 0xba, 0xb9, 0x19, 0x04, 0x2a, 0x02, 0x50, - 0x01, 0x52, 0x0c, 0x74, 0x65, 0x73, 0x74, 0x54, 0x61, 0x67, 0x41, 0x73, 0x73, 0x6f, 0x63, 0x3a, - 0x06, 0xba, 0xb9, 0x19, 0x02, 0x08, 0x01, 0x22, 0x7a, 0x0a, 0x15, 0x54, 0x65, 0x73, 0x74, 0x41, - 0x73, 0x73, 0x6f, 0x63, 0x48, 0x61, 0x6e, 0x64, 0x6c, 0x65, 0x72, 0x43, 0x6c, 0x65, 0x61, 0x72, + 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x06, 0xba, 0xb9, 0x19, 0x02, 0x2a, 0x00, 0x52, + 0x0c, 0x74, 0x65, 0x73, 0x74, 0x54, 0x61, 0x67, 0x41, 0x73, 0x73, 0x6f, 0x63, 0x3a, 0x06, 0xba, + 0xb9, 0x19, 0x02, 0x08, 0x01, 0x22, 0x7c, 0x0a, 0x17, 0x54, 0x65, 0x73, 0x74, 0x41, 0x73, 0x73, + 0x6f, 0x63, 0x48, 0x61, 0x6e, 0x64, 0x6c, 0x65, 0x72, 0x52, 0x65, 0x70, 0x6c, 0x61, 0x63, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x49, 0x0a, 0x0c, 0x74, 0x65, 0x73, 0x74, 0x54, 0x61, 0x67, 0x41, 0x73, 0x73, 0x6f, 0x63, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x54, 0x65, 0x73, 0x74, 0x54, 0x61, 0x67, 0x41, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, - 0x69, 0x6f, 0x6e, 0x42, 0x08, 0xba, 0xb9, 0x19, 0x04, 0x2a, 0x02, 0x60, 0x01, 0x52, 0x0c, 0x74, + 0x69, 0x6f, 0x6e, 0x42, 0x08, 0xba, 0xb9, 0x19, 0x04, 0x2a, 0x02, 0x50, 0x01, 0x52, 0x0c, 0x74, 0x65, 0x73, 0x74, 0x54, 0x61, 0x67, 0x41, 0x73, 0x73, 0x6f, 0x63, 0x3a, 0x06, 0xba, 0xb9, 0x19, - 0x02, 0x08, 0x01, 0x22, 0x7b, 0x0a, 0x16, 0x54, 0x65, 0x73, 0x74, 0x41, 0x73, 0x73, 0x6f, 0x63, - 0x48, 0x61, 0x6e, 0x64, 0x6c, 0x65, 0x72, 0x41, 0x70, 0x70, 0x65, 0x6e, 0x64, 0x12, 0x0e, 0x0a, - 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x49, 0x0a, - 0x0c, 0x74, 0x65, 0x73, 0x74, 0x54, 0x61, 0x67, 0x41, 0x73, 0x73, 0x6f, 0x63, 0x18, 0x02, 0x20, - 0x03, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x54, 0x65, - 0x73, 0x74, 0x54, 0x61, 0x67, 0x41, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, - 0x42, 0x08, 0xba, 0xb9, 0x19, 0x04, 0x2a, 0x02, 0x58, 0x01, 0x52, 0x0c, 0x74, 0x65, 0x73, 0x74, - 0x54, 0x61, 0x67, 0x41, 0x73, 0x73, 0x6f, 0x63, 0x3a, 0x06, 0xba, 0xb9, 0x19, 0x02, 0x08, 0x01, - 0x22, 0x3b, 0x0a, 0x12, 0x54, 0x65, 0x73, 0x74, 0x54, 0x61, 0x67, 0x41, 0x73, 0x73, 0x6f, 0x63, - 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x6f, 0x6d, 0x65, 0x5f, 0x66, - 0x69, 0x65, 0x6c, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x6f, 0x6d, 0x65, - 0x46, 0x69, 0x65, 0x6c, 0x64, 0x3a, 0x06, 0xba, 0xb9, 0x19, 0x02, 0x08, 0x01, 0x22, 0x53, 0x0a, - 0x0f, 0x50, 0x72, 0x69, 0x6d, 0x61, 0x72, 0x79, 0x49, 0x6e, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x64, - 0x12, 0x2c, 0x0a, 0x05, 0x63, 0x68, 0x69, 0x6c, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, - 0x16, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x45, 0x78, 0x74, 0x65, 0x72, 0x6e, - 0x61, 0x6c, 0x43, 0x68, 0x69, 0x6c, 0x64, 0x52, 0x05, 0x63, 0x68, 0x69, 0x6c, 0x64, 0x3a, 0x12, - 0xba, 0xb9, 0x19, 0x0e, 0x08, 0x01, 0x12, 0x0a, 0x0a, 0x04, 0x55, 0x55, 0x49, 0x44, 0x12, 0x02, - 0x69, 0x64, 0x42, 0x46, 0x5a, 0x44, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, - 0x2f, 0x69, 0x6e, 0x66, 0x6f, 0x62, 0x6c, 0x6f, 0x78, 0x6f, 0x70, 0x65, 0x6e, 0x2f, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x63, 0x2d, 0x67, 0x65, 0x6e, 0x2d, 0x67, 0x6f, 0x72, 0x6d, 0x2f, 0x65, 0x78, - 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2f, 0x66, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x5f, 0x64, 0x65, - 0x6d, 0x6f, 0x3b, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x33, + 0x02, 0x08, 0x01, 0x22, 0x7a, 0x0a, 0x15, 0x54, 0x65, 0x73, 0x74, 0x41, 0x73, 0x73, 0x6f, 0x63, + 0x48, 0x61, 0x6e, 0x64, 0x6c, 0x65, 0x72, 0x43, 0x6c, 0x65, 0x61, 0x72, 0x12, 0x0e, 0x0a, 0x02, + 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x49, 0x0a, 0x0c, + 0x74, 0x65, 0x73, 0x74, 0x54, 0x61, 0x67, 0x41, 0x73, 0x73, 0x6f, 0x63, 0x18, 0x02, 0x20, 0x03, + 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x54, 0x65, 0x73, + 0x74, 0x54, 0x61, 0x67, 0x41, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x42, + 0x08, 0xba, 0xb9, 0x19, 0x04, 0x2a, 0x02, 0x60, 0x01, 0x52, 0x0c, 0x74, 0x65, 0x73, 0x74, 0x54, + 0x61, 0x67, 0x41, 0x73, 0x73, 0x6f, 0x63, 0x3a, 0x06, 0xba, 0xb9, 0x19, 0x02, 0x08, 0x01, 0x22, + 0x7b, 0x0a, 0x16, 0x54, 0x65, 0x73, 0x74, 0x41, 0x73, 0x73, 0x6f, 0x63, 0x48, 0x61, 0x6e, 0x64, + 0x6c, 0x65, 0x72, 0x41, 0x70, 0x70, 0x65, 0x6e, 0x64, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x49, 0x0a, 0x0c, 0x74, 0x65, 0x73, + 0x74, 0x54, 0x61, 0x67, 0x41, 0x73, 0x73, 0x6f, 0x63, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, + 0x1b, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x54, 0x65, 0x73, 0x74, 0x54, 0x61, + 0x67, 0x41, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x08, 0xba, 0xb9, + 0x19, 0x04, 0x2a, 0x02, 0x58, 0x01, 0x52, 0x0c, 0x74, 0x65, 0x73, 0x74, 0x54, 0x61, 0x67, 0x41, + 0x73, 0x73, 0x6f, 0x63, 0x3a, 0x06, 0xba, 0xb9, 0x19, 0x02, 0x08, 0x01, 0x22, 0x3b, 0x0a, 0x12, + 0x54, 0x65, 0x73, 0x74, 0x54, 0x61, 0x67, 0x41, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x6f, 0x6d, 0x65, 0x5f, 0x66, 0x69, 0x65, 0x6c, 0x64, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x6f, 0x6d, 0x65, 0x46, 0x69, 0x65, 0x6c, + 0x64, 0x3a, 0x06, 0xba, 0xb9, 0x19, 0x02, 0x08, 0x01, 0x22, 0x53, 0x0a, 0x0f, 0x50, 0x72, 0x69, + 0x6d, 0x61, 0x72, 0x79, 0x49, 0x6e, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x64, 0x12, 0x2c, 0x0a, 0x05, + 0x63, 0x68, 0x69, 0x6c, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x65, 0x78, + 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x45, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x43, 0x68, + 0x69, 0x6c, 0x64, 0x52, 0x05, 0x63, 0x68, 0x69, 0x6c, 0x64, 0x3a, 0x12, 0xba, 0xb9, 0x19, 0x0e, + 0x08, 0x01, 0x12, 0x0a, 0x0a, 0x04, 0x55, 0x55, 0x49, 0x44, 0x12, 0x02, 0x69, 0x64, 0x42, 0x46, + 0x5a, 0x44, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x69, 0x6e, 0x66, + 0x6f, 0x62, 0x6c, 0x6f, 0x78, 0x6f, 0x70, 0x65, 0x6e, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, + 0x2d, 0x67, 0x65, 0x6e, 0x2d, 0x67, 0x6f, 0x72, 0x6d, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, + 0x65, 0x2f, 0x66, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x5f, 0x64, 0x65, 0x6d, 0x6f, 0x3b, 0x65, + 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -1264,12 +1274,13 @@ var file_feature_demo_demo_types_proto_goTypes = []interface{}{ (*types.JSONValue)(nil), // 19: gorm.types.JSONValue (*types.UUIDValue)(nil), // 20: gorm.types.UUIDValue (*types.TimeOnly)(nil), // 21: gorm.types.TimeOnly - (*IntPoint)(nil), // 22: example.IntPoint - (*user.User)(nil), // 23: user.User - (*types.InetValue)(nil), // 24: gorm.types.InetValue - (*wrapperspb.FloatValue)(nil), // 25: google.protobuf.FloatValue - (*wrapperspb.DoubleValue)(nil), // 26: google.protobuf.DoubleValue - (*ExternalChild)(nil), // 27: example.ExternalChild + (*types.BigInt)(nil), // 22: gorm.types.BigInt + (*IntPoint)(nil), // 23: example.IntPoint + (*user.User)(nil), // 24: user.User + (*types.InetValue)(nil), // 25: gorm.types.InetValue + (*wrapperspb.FloatValue)(nil), // 26: google.protobuf.FloatValue + (*wrapperspb.DoubleValue)(nil), // 27: google.protobuf.DoubleValue + (*ExternalChild)(nil), // 28: example.ExternalChild } var file_feature_demo_demo_types_proto_depIdxs = []int32{ 15, // 0: example.TestTypes.optional_string:type_name -> google.protobuf.StringValue @@ -1280,30 +1291,31 @@ var file_feature_demo_demo_types_proto_depIdxs = []int32{ 19, // 5: example.TestTypes.json_field:type_name -> gorm.types.JSONValue 20, // 6: example.TestTypes.nullable_uuid:type_name -> gorm.types.UUIDValue 21, // 7: example.TestTypes.time_only:type_name -> gorm.types.TimeOnly - 1, // 8: example.TypeWithID.things:type_name -> example.TestTypes - 1, // 9: example.TypeWithID.a_nested_object:type_name -> example.TestTypes - 22, // 10: example.TypeWithID.point:type_name -> example.IntPoint - 23, // 11: example.TypeWithID.user:type_name -> user.User - 24, // 12: example.TypeWithID.address:type_name -> gorm.types.InetValue - 5, // 13: example.TypeWithID.synthetic_field:type_name -> example.APIOnlyType - 25, // 14: example.TypeWithID.float_field:type_name -> google.protobuf.FloatValue - 26, // 15: example.TypeWithID.double_field:type_name -> google.protobuf.DoubleValue - 21, // 16: example.TypeWithID.time_only:type_name -> gorm.types.TimeOnly - 18, // 17: example.TypeWithID.deleted_at:type_name -> google.protobuf.Timestamp - 20, // 18: example.PrimaryUUIDType.id:type_name -> gorm.types.UUIDValue - 27, // 19: example.PrimaryUUIDType.child:type_name -> example.ExternalChild - 27, // 20: example.PrimaryStringType.child:type_name -> example.ExternalChild - 13, // 21: example.TestTag.testTagAssoc:type_name -> example.TestTagAssociation - 13, // 22: example.TestAssocHandlerDefault.testTagAssoc:type_name -> example.TestTagAssociation - 13, // 23: example.TestAssocHandlerReplace.testTagAssoc:type_name -> example.TestTagAssociation - 13, // 24: example.TestAssocHandlerClear.testTagAssoc:type_name -> example.TestTagAssociation - 13, // 25: example.TestAssocHandlerAppend.testTagAssoc:type_name -> example.TestTagAssociation - 27, // 26: example.PrimaryIncluded.child:type_name -> example.ExternalChild - 27, // [27:27] is the sub-list for method output_type - 27, // [27:27] is the sub-list for method input_type - 27, // [27:27] is the sub-list for extension type_name - 27, // [27:27] is the sub-list for extension extendee - 0, // [0:27] is the sub-list for field type_name + 22, // 8: example.TestTypes.bigint:type_name -> gorm.types.BigInt + 1, // 9: example.TypeWithID.things:type_name -> example.TestTypes + 1, // 10: example.TypeWithID.a_nested_object:type_name -> example.TestTypes + 23, // 11: example.TypeWithID.point:type_name -> example.IntPoint + 24, // 12: example.TypeWithID.user:type_name -> user.User + 25, // 13: example.TypeWithID.address:type_name -> gorm.types.InetValue + 5, // 14: example.TypeWithID.synthetic_field:type_name -> example.APIOnlyType + 26, // 15: example.TypeWithID.float_field:type_name -> google.protobuf.FloatValue + 27, // 16: example.TypeWithID.double_field:type_name -> google.protobuf.DoubleValue + 21, // 17: example.TypeWithID.time_only:type_name -> gorm.types.TimeOnly + 18, // 18: example.TypeWithID.deleted_at:type_name -> google.protobuf.Timestamp + 20, // 19: example.PrimaryUUIDType.id:type_name -> gorm.types.UUIDValue + 28, // 20: example.PrimaryUUIDType.child:type_name -> example.ExternalChild + 28, // 21: example.PrimaryStringType.child:type_name -> example.ExternalChild + 13, // 22: example.TestTag.testTagAssoc:type_name -> example.TestTagAssociation + 13, // 23: example.TestAssocHandlerDefault.testTagAssoc:type_name -> example.TestTagAssociation + 13, // 24: example.TestAssocHandlerReplace.testTagAssoc:type_name -> example.TestTagAssociation + 13, // 25: example.TestAssocHandlerClear.testTagAssoc:type_name -> example.TestTagAssociation + 13, // 26: example.TestAssocHandlerAppend.testTagAssoc:type_name -> example.TestTagAssociation + 28, // 27: example.PrimaryIncluded.child:type_name -> example.ExternalChild + 28, // [28:28] is the sub-list for method output_type + 28, // [28:28] is the sub-list for method input_type + 28, // [28:28] is the sub-list for extension type_name + 28, // [28:28] is the sub-list for extension extendee + 0, // [0:28] is the sub-list for field type_name } func init() { file_feature_demo_demo_types_proto_init() } diff --git a/example/feature_demo/demo_types.pb.gorm.go b/example/feature_demo/demo_types.pb.gorm.go index 020de06b..52fb901b 100644 --- a/example/feature_demo/demo_types.pb.gorm.go +++ b/example/feature_demo/demo_types.pb.gorm.go @@ -17,6 +17,7 @@ import ( emptypb "google.golang.org/protobuf/types/known/emptypb" timestamppb "google.golang.org/protobuf/types/known/timestamppb" wrapperspb "google.golang.org/protobuf/types/known/wrapperspb" + big "math/big" strings "strings" time "time" ) @@ -26,6 +27,7 @@ type TestTypesORM struct { Array pq.StringArray Array2 pq.StringArray BecomesInt string + Bigint *big.Int `gorm:"type:numeric"` CreatedAt *time.Time JsonField *postgres.Jsonb `gorm:"type:jsonb"` NullableUuid *go_uuid.UUID `gorm:"type:uuid"` @@ -85,6 +87,14 @@ func (m *TestTypes) ToORM(ctx context.Context) (TestTypesORM, error) { return to, err } } + if m.Bigint != nil { + var ok bool + to.Bigint = new(big.Int) + to.Bigint, ok = to.Bigint.SetString(m.Bigint.Value, 0) + if !ok { + return to, fmt.Errorf("unable convert Bigint to big.Int") + } + } if posthook, ok := interface{}(m).(TestTypesWithAfterToORM); ok { err = posthook.AfterToORM(ctx, &to) } @@ -122,6 +132,7 @@ func (m *TestTypesORM) ToPB(ctx context.Context) (TestTypes, error) { return to, err } } + to.Bigint = &types.BigInt{Value: m.Bigint.String()} if posthook, ok := interface{}(m).(TestTypesWithAfterToPB); ok { err = posthook.AfterToPB(ctx, &to) } @@ -1394,6 +1405,10 @@ func DefaultApplyFieldMaskTestTypes(ctx context.Context, patchee *TestTypes, pat patchee.TimeOnly = patcher.TimeOnly continue } + if f == prefix+"Bigint" { + patchee.Bigint = patcher.Bigint + continue + } } if err != nil { return nil, err diff --git a/example/feature_demo/demo_types.proto b/example/feature_demo/demo_types.proto index c04c1553..3ae17426 100644 --- a/example/feature_demo/demo_types.proto +++ b/example/feature_demo/demo_types.proto @@ -66,6 +66,7 @@ message TestTypes { // The TimeOnly should act as uint32 value at business layer, but is automatically // converted to/from string at API and ORM level gorm.types.TimeOnly time_only = 11; + gorm.types.BigInt bigint = 12; } // TypeWithID demonstrates some basic assocation behavior diff --git a/example/feature_demo/marshal_test.go b/example/feature_demo/marshal_test.go index 6569cfd7..5e5a8363 100644 --- a/example/feature_demo/marshal_test.go +++ b/example/feature_demo/marshal_test.go @@ -87,16 +87,17 @@ func TestMarshalTypes(t *testing.T) { // Will marshal with snake_case names and default values included marshaler := &jsonpb.Marshaler{OrigName: true, EmitDefaults: true} for expected, in := range map[string]TestTypes{ - `{"api_only_string":"","numbers":[],"optional_string":null,"becomes_int":"UNKNOWN","nothingness":null,"uuid":null,"created_at":null,"type_with_id_id":0,"json_field":null,"nullable_uuid":null,"time_only":null}`: {}, - `{"api_only_string":"Something","numbers":[],"optional_string":null,"becomes_int":"UNKNOWN","nothingness":null,"uuid":null,"created_at":null,"type_with_id_id":0,"json_field":null,"nullable_uuid":null,"time_only":null}`: {ApiOnlyString: "Something"}, - `{"api_only_string":"","numbers":[0,1,2,3],"optional_string":null,"becomes_int":"UNKNOWN","nothingness":null,"uuid":null,"created_at":null,"type_with_id_id":0,"json_field":null,"nullable_uuid":null,"time_only":null}`: {Numbers: []int32{0, 1, 2, 3}}, - `{"api_only_string":"","numbers":[],"optional_string":"Not nothing","becomes_int":"UNKNOWN","nothingness":null,"uuid":null,"created_at":null,"type_with_id_id":0,"json_field":null,"nullable_uuid":null,"time_only":null}`: {OptionalString: &wrappers.StringValue{Value: "Not nothing"}}, - `{"api_only_string":"","numbers":[],"optional_string":null,"becomes_int":"GOOD","nothingness":null,"uuid":null,"created_at":null,"type_with_id_id":0,"json_field":null,"nullable_uuid":null,"time_only":null}`: {BecomesInt: TestTypes_GOOD}, - `{"api_only_string":"","numbers":[],"optional_string":null,"becomes_int":"UNKNOWN","nothingness":null,"uuid":"6ba7b810-9dad-11d1-80b4-00c04fd430c8","created_at":null,"type_with_id_id":0,"json_field":null,"nullable_uuid":null,"time_only":null}`: {Uuid: &types.UUID{Value: "6ba7b810-9dad-11d1-80b4-00c04fd430c8"}}, - `{"api_only_string":"","numbers":[],"optional_string":null,"becomes_int":"UNKNOWN","nothingness":null,"uuid":null,"created_at":"2009-11-17T20:34:58.651387237Z","type_with_id_id":0,"json_field":null,"nullable_uuid":null,"time_only":null}`: {CreatedAt: MustTimestampProto(time.Date(2009, 11, 17, 20, 34, 58, 651387237, time.UTC))}, - `{"api_only_string":"","numbers":[],"optional_string":null,"becomes_int":"UNKNOWN","nothingness":null,"uuid":null,"created_at":null,"type_with_id_id":2,"json_field":null,"nullable_uuid":null,"time_only":null}`: {TypeWithIdId: 2}, - `{"api_only_string":"","numbers":[],"optional_string":null,"becomes_int":"UNKNOWN","nothingness":null,"uuid":null,"created_at":null,"type_with_id_id":0,"json_field":{"text":[]},"nullable_uuid":null,"time_only":null}`: {JsonField: &types.JSONValue{Value: `{"text":[]}`}}, - `{"api_only_string":"","numbers":[],"optional_string":null,"becomes_int":"UNKNOWN","nothingness":null,"uuid":null,"created_at":null,"type_with_id_id":0,"json_field":null,"nullable_uuid":null,"time_only":"01:59:18"}`: {TimeOnly: &types.TimeOnly{Value: 7158}}, + `{"api_only_string":"","numbers":[],"optional_string":null,"becomes_int":"UNKNOWN","nothingness":null,"uuid":null,"created_at":null,"type_with_id_id":0,"json_field":null,"nullable_uuid":null,"time_only":null,"bigint":null}`: {}, + `{"api_only_string":"Something","numbers":[],"optional_string":null,"becomes_int":"UNKNOWN","nothingness":null,"uuid":null,"created_at":null,"type_with_id_id":0,"json_field":null,"nullable_uuid":null,"time_only":null,"bigint":null}`: {ApiOnlyString: "Something"}, + `{"api_only_string":"","numbers":[0,1,2,3],"optional_string":null,"becomes_int":"UNKNOWN","nothingness":null,"uuid":null,"created_at":null,"type_with_id_id":0,"json_field":null,"nullable_uuid":null,"time_only":null,"bigint":null}`: {Numbers: []int32{0, 1, 2, 3}}, + `{"api_only_string":"","numbers":[],"optional_string":"Not nothing","becomes_int":"UNKNOWN","nothingness":null,"uuid":null,"created_at":null,"type_with_id_id":0,"json_field":null,"nullable_uuid":null,"time_only":null,"bigint":null}`: {OptionalString: &wrappers.StringValue{Value: "Not nothing"}}, + `{"api_only_string":"","numbers":[],"optional_string":null,"becomes_int":"GOOD","nothingness":null,"uuid":null,"created_at":null,"type_with_id_id":0,"json_field":null,"nullable_uuid":null,"time_only":null,"bigint":null}`: {BecomesInt: TestTypes_GOOD}, + `{"api_only_string":"","numbers":[],"optional_string":null,"becomes_int":"UNKNOWN","nothingness":null,"uuid":"6ba7b810-9dad-11d1-80b4-00c04fd430c8","created_at":null,"type_with_id_id":0,"json_field":null,"nullable_uuid":null,"time_only":null,"bigint":null}`: {Uuid: &types.UUID{Value: "6ba7b810-9dad-11d1-80b4-00c04fd430c8"}}, + `{"api_only_string":"","numbers":[],"optional_string":null,"becomes_int":"UNKNOWN","nothingness":null,"uuid":null,"created_at":"2009-11-17T20:34:58.651387237Z","type_with_id_id":0,"json_field":null,"nullable_uuid":null,"time_only":null,"bigint":null}`: {CreatedAt: MustTimestampProto(time.Date(2009, 11, 17, 20, 34, 58, 651387237, time.UTC))}, + `{"api_only_string":"","numbers":[],"optional_string":null,"becomes_int":"UNKNOWN","nothingness":null,"uuid":null,"created_at":null,"type_with_id_id":2,"json_field":null,"nullable_uuid":null,"time_only":null,"bigint":null}`: {TypeWithIdId: 2}, + `{"api_only_string":"","numbers":[],"optional_string":null,"becomes_int":"UNKNOWN","nothingness":null,"uuid":null,"created_at":null,"type_with_id_id":0,"json_field":{"text":[]},"nullable_uuid":null,"time_only":null,"bigint":null}`: {JsonField: &types.JSONValue{Value: `{"text":[]}`}}, + `{"api_only_string":"","numbers":[],"optional_string":null,"becomes_int":"UNKNOWN","nothingness":null,"uuid":null,"created_at":null,"type_with_id_id":0,"json_field":null,"nullable_uuid":null,"time_only":"01:59:18","bigint":null}`: {TimeOnly: &types.TimeOnly{Value: 7158}}, + `{"api_only_string":"","numbers":[],"optional_string":null,"becomes_int":"UNKNOWN","nothingness":null,"uuid":null,"created_at":null,"type_with_id_id":0,"json_field":null,"nullable_uuid":null,"time_only":null,"bigint":"7158"}`: {Bigint: &types.BigInt{Value: "7158"}}, } { out, err := marshaler.MarshalToString(&in) if err != nil { @@ -141,4 +142,4 @@ func MustTimestampProto(t time.Time) *timestamp.Timestamp { panic(err) } return ts -} \ No newline at end of file +} diff --git a/go.mod b/go.mod index b8675cf8..9c374fc6 100644 --- a/go.mod +++ b/go.mod @@ -13,10 +13,13 @@ require ( github.com/mattn/go-sqlite3 v1.14.6 // indirect github.com/satori/go.uuid v1.2.0 go.opencensus.io v0.22.6 - google.golang.org/genproto v0.0.0-20210426193834-eac7f76ac494 - google.golang.org/grpc v1.37.0 + golang.org/x/net v0.0.0-20220114011407-0dd24b26b47d // indirect + golang.org/x/sys v0.0.0-20220114195835-da31bd327af9 // indirect + golang.org/x/text v0.3.7 // indirect + google.golang.org/genproto v0.0.0-20220118154757-00ab72f36ad5 + google.golang.org/grpc v1.43.0 google.golang.org/grpc/examples v0.0.0-20210601155443-8bdcb4c9ab8d // indirect - google.golang.org/protobuf v1.26.0 + google.golang.org/protobuf v1.27.1 ) go 1.16 diff --git a/go.sum b/go.sum index 134b441b..f234237f 100644 --- a/go.sum +++ b/go.sum @@ -55,12 +55,18 @@ github.com/bketelsen/crypt v0.0.3-0.20200106085610-5cbc8cc4026c/go.mod h1:MKsuJm github.com/bufbuild/buf v0.37.0/go.mod h1:lQ1m2HkIaGOFba6w/aC3KYBHhKEOESP3gaAEpS3dAFM= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= +github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= +github.com/cncf/udpa/go v0.0.0-20210930031921-04548b0d99d4/go.mod h1:6pvJx4me5XPnfI9Z40ddWsdw2W/uZgQLFXToKeRcDiI= +github.com/cncf/xds/go v0.0.0-20210312221358-fbca930ec8ed/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= +github.com/cncf/xds/go v0.0.0-20210805033703-aa0b78936158/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= +github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= +github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk= github.com/coreos/etcd v3.3.13+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= @@ -82,6 +88,8 @@ github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.m github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= github.com/envoyproxy/go-control-plane v0.9.9-0.20210217033140-668b12f5399d/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= +github.com/envoyproxy/go-control-plane v0.9.9-0.20210512163311-63b5d3c536b0/go.mod h1:hliV/p42l8fGbc6Y9bQ70uLwIvmJyVE5k4iMKlh8wCQ= +github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021/go.mod h1:AFq3mo9L8Lqqiid3OhADV3RfLJnjiw63cSpi+fDTRC0= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/erikstmartin/go-testdb v0.0.0-20160219214506-8d10e4a1bae5 h1:Yzb9+7DPaBjB8zlTR87/ElzFsnQfuHnVUVqpZZIcV5Y= github.com/erikstmartin/go-testdb v0.0.0-20160219214506-8d10e4a1bae5/go.mod h1:a2zkGnVExMxdzMo3M0Hi/3sEU+cWnZpSni0O6/Yb/P0= @@ -174,6 +182,8 @@ github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgf github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= github.com/grpc-ecosystem/grpc-gateway v1.14.6 h1:8ERzHx8aj1Sc47mu9n/AksaKCSWrMchFtkdrS4BIj5o= github.com/grpc-ecosystem/grpc-gateway v1.14.6/go.mod h1:zdiPV4Yse/1gnckTHtghG4GkDEdKCRJduHpTxT3/jcw= +github.com/grpc-ecosystem/grpc-gateway v1.16.0 h1:gmcG1KaJ57LophUzW0Hy8NmPhnMZb4M0+kPpLofRdBo= +github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= github.com/grpc-ecosystem/grpc-gateway/v2 v2.3.0/go.mod h1:d2gYTOTUQklu06xp0AJYYmRdTVU1VKrqhkYfYag2L08= github.com/grpc-ecosystem/grpc-gateway/v2 v2.4.0 h1:R+ZwHcCaBVMLvCQzo/lhJCYkjkL7G506oi2N8SIob/g= github.com/grpc-ecosystem/grpc-gateway/v2 v2.4.0/go.mod h1:IOyTYjcIO0rkmnGBfJTL0NJ11exy/Tc2QEuv7hCXp24= @@ -321,6 +331,7 @@ go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.6 h1:BdkrbWrzDlV9dnbzoP7sfN+dHheJ4J9JOaYxcUDL+ok= go.opencensus.io v0.22.6/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E= +go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= @@ -410,6 +421,9 @@ golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwY golang.org/x/net v0.0.0-20210119194325-5f4716e94777/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210316092652-d523dce5a7f4 h1:b0LrWgu8+q7z4J+0Y3Umo5q1dL7NXBkKBWkaVkAq17E= golang.org/x/net v0.0.0-20210316092652-d523dce5a7f4/go.mod h1:RBQZq4jEuRlivfhVLdyRGr576XBO4/greRjx4P4O3yc= +golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= +golang.org/x/net v0.0.0-20220114011407-0dd24b26b47d h1:1n1fc535VhN8SYtD4cDUyNlfpAF2ROMM9+11equK3hs= +golang.org/x/net v0.0.0-20220114011407-0dd24b26b47d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -467,6 +481,11 @@ golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210315160823-c6e025ad8005/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4 h1:EZ2mChiOa8udjfp6rRmswTbtZN/QzUQp4ptM4rnjHvc= golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220114195835-da31bd327af9 h1:XfKQ4OlFl8okEOr5UvAqFRVj8pY/4yfcXrddB8qAbU0= +golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -475,6 +494,9 @@ golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.5 h1:i6eZZ+zk0SOf0xgBpEpPD18qWcJda6q1sxt3S0kzyUQ= golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= +golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -592,6 +614,8 @@ google.golang.org/genproto v0.0.0-20210207032614-bba0dbe2a9ea/go.mod h1:FWY/as6D google.golang.org/genproto v0.0.0-20210224155714-063164c882e6/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20210426193834-eac7f76ac494 h1:KMgpo2lWy1vfrYjtxPAzR0aNWeAR1UdQykt6sj/hpBY= google.golang.org/genproto v0.0.0-20210426193834-eac7f76ac494/go.mod h1:P3QM42oQyzQSnHPnZ/vqoCdDmzH28fzWByN9asMeM8A= +google.golang.org/genproto v0.0.0-20220118154757-00ab72f36ad5 h1:zzNejm+EgrbLfDZ6lu9Uud2IVvHySPl8vQzf04laR5Q= +google.golang.org/genproto v0.0.0-20220118154757-00ab72f36ad5/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= @@ -604,12 +628,16 @@ google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKa google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= +google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0= google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc= google.golang.org/grpc v1.35.0-dev.0.20201218190559-666aea1fb34c/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= google.golang.org/grpc v1.36.1/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= google.golang.org/grpc v1.37.0 h1:uSZWeQJX5j11bIQ4AJoj+McDBo29cY1MCoC1wO3ts+c= google.golang.org/grpc v1.37.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= +google.golang.org/grpc v1.40.0/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34= +google.golang.org/grpc v1.43.0 h1:Eeu7bZtDZ2DpRCsLhUlcrLnvYaMK1Gz86a+hMVvELmM= +google.golang.org/grpc v1.43.0/go.mod h1:k+4IHHFw41K8+bbowsex27ge2rCb65oeWqe4jJ590SU= google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.0.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw= google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw= google.golang.org/grpc/examples v0.0.0-20210309220351-d5b628860d4e/go.mod h1:Ly7ZA/ARzg8fnPU9TyZIxoz33sEUuWX7txiqs8lPTgE= @@ -628,8 +656,9 @@ google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlba google.golang.org/protobuf v1.25.1-0.20200805231151-a709e31e5d12/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= google.golang.org/protobuf v1.25.1-0.20201208041424-160c7477e0e8/go.mod h1:hFxJC2f0epmp1elRCiEGJTKAWbwxZ2nvqZdHl3FQXCY= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= -google.golang.org/protobuf v1.26.0 h1:bxAC2xTBsZGibn2RTntX0oH50xLsqy1OxA9tTL3p/lk= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= +google.golang.org/protobuf v1.27.1 h1:SnqbnDw1V7RiZcXPx5MEeqPv2s79L9i7BJUlG/+RurQ= +google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= diff --git a/plugin/plugin.go b/plugin/plugin.go index c98012e2..790a1263 100644 --- a/plugin/plugin.go +++ b/plugin/plugin.go @@ -53,6 +53,7 @@ var ( stdStringsImport = "strings" stdTimeImport = "time" encodingJsonImport = "encoding/json" + bigintImport = "math/big" ) var builtinTypes = map[string]struct{}{ @@ -94,6 +95,7 @@ const ( protoTypeResource = "Identifier" protoTypeInet = "InetValue" protoTimeOnly = "TimeOnly" + protoTypeBigInt = "BigInt" ) // DB Engine Enum @@ -430,6 +432,7 @@ func (b *ORMBuilder) generateOrmable(g *protogen.GeneratedFile, message *protoge for _, name := range names { field := ormable.Fields[name] sp := strings.Split(field.Type, ".") + if len(sp) == 2 && sp[1] == "UUID" { s := generateImport("UUID", uuidImport, g) if field.Type[0] == '*' { @@ -439,6 +442,15 @@ func (b *ORMBuilder) generateOrmable(g *protogen.GeneratedFile, message *protoge } } + if len(sp) == 2 && sp[1] == "BigInt" { + s := generateImport("BigInt", bigintImport, g) + if field.Type[0] == '*' { + field.Type = "*" + s + } else { + field.Type = s + } + } + g.P(name, ` `, field.Type, b.renderGormTag(field)) } @@ -841,6 +853,12 @@ func (b *ORMBuilder) parseBasicFields(msg *protogen.Message, g *protogen.Generat if v, ok := wellKnownTypes[rawType]; ok { fieldType = v + } else if rawType == protoTypeBigInt { + typePackage = bigintImport + fieldType = "*" + generateImport("Int", bigintImport, g) + if b.dbEngine == ENGINE_POSTGRES { + gormOptions.Tag = tagWithType(tag, "numeric") + } } else if rawType == protoTypeUUID { typePackage = uuidImport fieldType = generateImport("UUID", uuidImport, g) @@ -967,6 +985,8 @@ func (b *ORMBuilder) addIncludedField(ormable *OrmableType, field *gorm.ExtraFie } else if rawType == "Time" { // b.UsingGoImports(stdTimeImport) // TODO: missing UsingGoImports rawType = generateImport("Time", stdTimeImport, g) + } else if rawType == "BigInt" { + rawType = generateImport("Int", bigintImport, g) } else if rawType == "UUID" { rawType = generateImport("UUID", uuidImport, g) } else if field.GetType() == "Jsonb" && b.dbEngine == ENGINE_POSTGRES { @@ -1381,6 +1401,19 @@ func (b *ORMBuilder) generateFieldConversion(message *protogen.Message, field *p `{Value: *m.`, fieldName, `}`) g.P(`}`) } + } else if fieldType == protoTypeBigInt { // Singular BigInt type ---- + if toORM { + g.P(`if m.`, fieldName, ` != nil {`) + g.P(`var ok bool`) + g.P(`to.`, fieldName, ` = new(big.Int)`) + g.P(`to.`, fieldName, `, ok = to.`, fieldName, `.SetString(m.`, fieldName, `.Value, 0)`) + g.P(`if !ok {`) + g.P(`return to, fmt.Errorf("unable convert `, fieldName, ` to big.Int")`) + g.P(`}`) + g.P(`}`) + } else { + g.P(`to.`, fieldName, ` = &`, generateImport("BigInt", gtypesImport, g), `{Value: m.`, fieldName, `.String()}`) + } } else if fieldType == protoTypeUUIDValue { // Singular UUIDValue type ---- if toORM { g.P(`if m.`, fieldName, ` != nil {`) @@ -1705,9 +1738,11 @@ func (b *ORMBuilder) guessZeroValue(typeName string, g *protogen.GeneratedFile) return `0` } if strings.Contains(typeName, "uuid") { - // return fmt.Sprintf(`%s.Nil`, p.Import(uuidImport)) return generateImport("Nil", uuidImport, g) } + if strings.Contains(typeName, "bigint") { + return generateImport("Nil", bigintImport, g) + } if strings.Contains(typeName, "[]byte") { return `nil` } @@ -2354,7 +2389,7 @@ func (b *ORMBuilder) generateApplyFieldMask(message *protogen.Message, g *protog func isSpecialType(typeName string) bool { switch typeName { - case protoTypeJSON, protoTypeUUID, protoTypeUUIDValue, protoTypeResource, protoTypeInet, protoTimeOnly: + case protoTypeJSON, protoTypeBigInt, protoTypeUUID, protoTypeUUIDValue, protoTypeResource, protoTypeInet, protoTimeOnly: return true default: return false diff --git a/proto/types/types.proto b/proto/types/types.proto index 0f469175..3b62c2d0 100644 --- a/proto/types/types.proto +++ b/proto/types/types.proto @@ -21,4 +21,8 @@ message InetValue { message TimeOnly { uint32 value = 1; -} \ No newline at end of file +} + +message BigInt { + string value = 1; +} diff --git a/types/marshal_test.go b/types/marshal_test.go index c696a7c6..d2210849 100644 --- a/types/marshal_test.go +++ b/types/marshal_test.go @@ -15,6 +15,7 @@ type WrapperMessage struct { UUIDValue *UUIDValue `protobuf:"bytes,2,opt,name=uuid_value,json=uuid_value" json:"uuid_value,omitempty"` UUID *UUID `protobuf:"bytes,3,opt,name=uuid,json=uuid" json:"uuid,omitempty"` Inet *InetValue `protobuf:"bytes,4,opt,name=inet,json=inet" json:"inet,omitempty"` + BigInt *BigInt `protobuf:"bytes,5,opt,name=bigint,json=bigint" json:"bigint,omitempty"` } func (m *WrapperMessage) Reset() { @@ -31,7 +32,7 @@ func (m *WrapperMessage) ProtoMessage() { func TestSuccessfulUnmarshalTypes(t *testing.T) { unmarshaler := &jsonpb.Unmarshaler{} for in, expected := range map[string]WrapperMessage{ - `{}`: {JSON: nil, UUID: nil, Inet: nil}, + `{}`: {JSON: nil, UUID: nil, Inet: nil, BigInt: nil}, // Can't unmarshal 'null' to nil like a WKT, only an invalid, empty state // which will be remarshalled to 'null' `{"json":null}`: {JSON: &JSONValue{}}, @@ -43,6 +44,8 @@ func TestSuccessfulUnmarshalTypes(t *testing.T) { `{"uuid_value": "6ba7b8109dad11d180b400c04fd430c8" }`: {UUIDValue: &UUIDValue{Value: `6ba7b8109dad11d180b400c04fd430c8`}}, `{"inet": "1.2.3.4"}`: {Inet: &InetValue{Value: `1.2.3.4`}}, `{"inet":null}`: {Inet: &InetValue{Value: ""}}, + `{"bigint":null}`: {BigInt: &BigInt{Value: ""}}, + `{"bigint":"12345"}`: {BigInt: &BigInt{Value: "12345"}}, } { jv := WrapperMessage{} err := unmarshaler.Unmarshal(strings.NewReader(in), &jv) @@ -71,6 +74,7 @@ func TestBrokenUnmarshalTypes(t *testing.T) { `{"uuid_value":ba67b810-9dad-11d1-80b4-00c04fd430c8}`: "invalid character 'b' looking for beginning of value", `{"inet": 1.2.3.4}`: "invalid character '.' after object key:value pair", `{"inet": 1}`: "invalid inet '1' does not match accepted format", + `{"bigint": 1}`: "invalid bigint '1' does not match accepted format", } { err := unmarshaler.Unmarshal(strings.NewReader(in), &WrapperMessage{}) if err == nil || err.Error() != expected { @@ -86,11 +90,12 @@ func TestBrokenUnmarshalTypes(t *testing.T) { func TestMarshalTypes(t *testing.T) { marshaler := &jsonpb.Marshaler{OrigName: true, EmitDefaults: true} for expected, in := range map[string]WrapperMessage{ - `{"json":null,"uuid_value":null,"uuid":null,"inet":null}`: {}, - `{"json":null,"uuid_value":null,"uuid":"00000000-0000-0000-0000-000000000000","inet":null}`: {UUID: &UUID{}}, - `{"json":{"key": "value"},"uuid_value":"6ba7b810-9dad-11d1-80b4-00c04fd430c8","uuid":null,"inet":null}`: {JSON: &JSONValue{Value: `{"key": "value"}`}, UUIDValue: &UUIDValue{Value: `6ba7b810-9dad-11d1-80b4-00c04fd430c8`}}, - `{"json":{"key": "value"},"uuid_value":"6ba7b810-9dad-11d1-80b4-00c04fd430c8","uuid":null,"inet":"10.0.0.1"}`: {JSON: &JSONValue{Value: `{"key": "value"}`}, UUIDValue: &UUIDValue{Value: `6ba7b810-9dad-11d1-80b4-00c04fd430c8`}, Inet: &InetValue{Value: `10.0.0.1`}}, - `{"json":null,"uuid_value":"00000000-0000-0000-0000-000000000000","uuid":null,"inet":null}`: {UUIDValue: &UUIDValue{Value: "00000000-0000-0000-0000-000000000000"}}, + `{"json":null,"uuid_value":null,"uuid":null,"inet":null,"bigint":null}`: {}, + `{"json":null,"uuid_value":null,"uuid":"00000000-0000-0000-0000-000000000000","inet":null,"bigint":null}`: {UUID: &UUID{}}, + `{"json":{"key": "value"},"uuid_value":"6ba7b810-9dad-11d1-80b4-00c04fd430c8","uuid":null,"inet":null,"bigint":null}`: {JSON: &JSONValue{Value: `{"key": "value"}`}, UUIDValue: &UUIDValue{Value: `6ba7b810-9dad-11d1-80b4-00c04fd430c8`}}, + `{"json":{"key": "value"},"uuid_value":"6ba7b810-9dad-11d1-80b4-00c04fd430c8","uuid":null,"inet":"10.0.0.1","bigint":null}`: {JSON: &JSONValue{Value: `{"key": "value"}`}, UUIDValue: &UUIDValue{Value: `6ba7b810-9dad-11d1-80b4-00c04fd430c8`}, Inet: &InetValue{Value: `10.0.0.1`}}, + `{"json":null,"uuid_value":"00000000-0000-0000-0000-000000000000","uuid":null,"inet":null,"bigint":null}`: {UUIDValue: &UUIDValue{Value: "00000000-0000-0000-0000-000000000000"}}, + `{"json":null,"uuid_value":null,"uuid":null,"inet":null,"bigint":"12345"}`: {BigInt: &BigInt{Value: "12345"}}, } { out, err := marshaler.MarshalToString(&in) if err != nil { @@ -112,7 +117,8 @@ func TestMarshalTypesOmitEmpty(t *testing.T) { `{"json":{"key": "value"}}`: {JSON: &JSONValue{Value: `{"key": "value"}`}}, `{"uuid_value":"6ba7b810-9dad-11d1-80b4-00c04fd430c8"}`: {UUIDValue: &UUIDValue{Value: `6ba7b810-9dad-11d1-80b4-00c04fd430c8`}}, `{"json":{"key": "value"},"uuid_value":"6ba7b810-9dad-11d1-80b4-00c04fd430c8"}`: {JSON: &JSONValue{Value: `{"key": "value"}`}, UUIDValue: &UUIDValue{Value: `6ba7b810-9dad-11d1-80b4-00c04fd430c8`}}, - `{"inet":null}`: {Inet: &InetValue{}}, + `{"inet":null}`: {Inet: &InetValue{}}, + `{"bigint":null}`: {BigInt: &BigInt{}}, } { out, err := marshaller.MarshalToString(&in) if err != nil { diff --git a/types/types.override.pb.go b/types/types.override.pb.go index 9597036a..59058ba8 100644 --- a/types/types.override.pb.go +++ b/types/types.override.pb.go @@ -14,6 +14,30 @@ var validChars = regexp.MustCompile("^[0-9a-f]{8}-?[0-9a-f]{4}-?[1-5][0-9a-f]{3} // ZeroUUID The Zero value used for non-nil, but uninitialized UUID type const ZeroUUID = "00000000-0000-0000-0000-000000000000" +// MarshalJSONPB overloads UUID's standard PB -> JSON conversion +func (m *BigInt) MarshalJSONPB(*jsonpb.Marshaler) ([]byte, error) { + if len(m.Value) == 0 { + return []byte("null"), nil + } + return []byte(fmt.Sprintf("%q", m.Value)), nil +} + +// UnmarshalJSONPB overloads UUID's standard JSON -> PB conversion. +func (m *BigInt) UnmarshalJSONPB(_ *jsonpb.Unmarshaler, data []byte) error { + if string(data) == "null" { + m.Value = "" + return nil + } + + t := string(data) + if t[0] != '"' || t[len(t)-1] != '"' { + return fmt.Errorf(`invalid bigint '%s' does not match accepted format`, t) + } + + m.Value = strings.Trim(string(data), `"`) + return nil +} + // MarshalJSONPB overloads UUID's standard PB -> JSON conversion func (m *UUID) MarshalJSONPB(*jsonpb.Marshaler) ([]byte, error) { if len(m.Value) == 0 { diff --git a/types/types.pb.go b/types/types.pb.go index 4c19405e..ce804b9a 100644 --- a/types/types.pb.go +++ b/types/types.pb.go @@ -255,6 +255,53 @@ func (x *TimeOnly) GetValue() uint32 { return 0 } +type BigInt struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Value string `protobuf:"bytes,1,opt,name=value,proto3" json:"value,omitempty"` +} + +func (x *BigInt) Reset() { + *x = BigInt{} + if protoimpl.UnsafeEnabled { + mi := &file_types_types_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *BigInt) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*BigInt) ProtoMessage() {} + +func (x *BigInt) ProtoReflect() protoreflect.Message { + mi := &file_types_types_proto_msgTypes[5] + 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 BigInt.ProtoReflect.Descriptor instead. +func (*BigInt) Descriptor() ([]byte, []int) { + return file_types_types_proto_rawDescGZIP(), []int{5} +} + +func (x *BigInt) GetValue() string { + if x != nil { + return x.Value + } + return "" +} + var File_types_types_proto protoreflect.FileDescriptor var file_types_types_proto_rawDesc = []byte{ @@ -270,7 +317,9 @@ var file_types_types_proto_rawDesc = []byte{ 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x20, 0x0a, 0x08, 0x54, 0x69, 0x6d, 0x65, 0x4f, 0x6e, 0x6c, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x0d, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x42, 0x35, 0x5a, 0x33, 0x67, 0x69, 0x74, 0x68, + 0x0d, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x1e, 0x0a, 0x06, 0x42, 0x69, 0x67, 0x49, + 0x6e, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x42, 0x35, 0x5a, 0x33, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x69, 0x6e, 0x66, 0x6f, 0x62, 0x6c, 0x6f, 0x78, 0x6f, 0x70, 0x65, 0x6e, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x2d, 0x67, 0x65, 0x6e, 0x2d, 0x67, 0x6f, 0x72, 0x6d, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x3b, 0x74, 0x79, 0x70, 0x65, 0x73, 0x62, @@ -289,13 +338,14 @@ func file_types_types_proto_rawDescGZIP() []byte { return file_types_types_proto_rawDescData } -var file_types_types_proto_msgTypes = make([]protoimpl.MessageInfo, 5) +var file_types_types_proto_msgTypes = make([]protoimpl.MessageInfo, 6) var file_types_types_proto_goTypes = []interface{}{ (*UUIDValue)(nil), // 0: gorm.types.UUIDValue (*JSONValue)(nil), // 1: gorm.types.JSONValue (*UUID)(nil), // 2: gorm.types.UUID (*InetValue)(nil), // 3: gorm.types.InetValue (*TimeOnly)(nil), // 4: gorm.types.TimeOnly + (*BigInt)(nil), // 5: gorm.types.BigInt } var file_types_types_proto_depIdxs = []int32{ 0, // [0:0] is the sub-list for method output_type @@ -371,6 +421,18 @@ func file_types_types_proto_init() { return nil } } + file_types_types_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*BigInt); 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{ @@ -378,7 +440,7 @@ func file_types_types_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_types_types_proto_rawDesc, NumEnums: 0, - NumMessages: 5, + NumMessages: 6, NumExtensions: 0, NumServices: 0, },