├── 4-enum ├── README.md ├── go.mod ├── protos │ ├── order2.proto │ └── order3.proto ├── main_test.go ├── go.sum └── models │ ├── order2.pb.go │ └── order3.pb.go ├── 3-proto2-vs-proto3 ├── README.md ├── go.mod ├── protos │ ├── customer.proto │ ├── payment.proto │ └── order.proto ├── main_test.go ├── go.sum └── models │ ├── customer.pb.go │ ├── payment.pb.go │ └── order.pb.go ├── 2-top-level-statements ├── README.md ├── go.mod ├── protos │ ├── customer.proto │ └── order.proto ├── main_test.go ├── go.sum └── models │ ├── customer.pb.go │ └── order.pb.go └── 1-protobuf-vs-json ├── go.mod ├── person.proto ├── go.sum ├── README.md ├── main_test.go └── person.pb.go /4-enum/README.md: -------------------------------------------------------------------------------- 1 | ```sh 2 | protoc --go_out=./models ./protos/* 3 | go test -v . -bench=. 4 | ``` 5 | -------------------------------------------------------------------------------- /3-proto2-vs-proto3/README.md: -------------------------------------------------------------------------------- 1 | ```sh 2 | protoc --go_out=./models ./protos/* 3 | go test -v . -bench=. 4 | ``` 5 | -------------------------------------------------------------------------------- /2-top-level-statements/README.md: -------------------------------------------------------------------------------- 1 | ```sh 2 | protoc --go_out=./models ./protos/* 3 | go test -v . -bench=. 4 | ``` 5 | -------------------------------------------------------------------------------- /4-enum/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/arpitbbhayani/protobuf 2 | 3 | go 1.22.1 4 | 5 | require github.com/golang/protobuf v1.5.4 6 | 7 | require google.golang.org/protobuf v1.33.0 // indirect 8 | -------------------------------------------------------------------------------- /1-protobuf-vs-json/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/arpitbbhayani/protobuf 2 | 3 | go 1.22.1 4 | 5 | require github.com/golang/protobuf v1.5.4 6 | 7 | require google.golang.org/protobuf v1.33.0 // indirect 8 | -------------------------------------------------------------------------------- /2-top-level-statements/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/arpitbbhayani/protobuf 2 | 3 | go 1.22.1 4 | 5 | require github.com/golang/protobuf v1.5.4 6 | 7 | require google.golang.org/protobuf v1.33.0 // indirect 8 | -------------------------------------------------------------------------------- /3-proto2-vs-proto3/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/arpitbbhayani/protobuf 2 | 3 | go 1.22.1 4 | 5 | require github.com/golang/protobuf v1.5.4 6 | 7 | require google.golang.org/protobuf v1.33.0 // indirect 8 | -------------------------------------------------------------------------------- /3-proto2-vs-proto3/protos/customer.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package models; 4 | option go_package = ".;models"; 5 | 6 | message Customer { 7 | string id = 1; 8 | string name = 2; 9 | string email = 3; 10 | } 11 | -------------------------------------------------------------------------------- /2-top-level-statements/protos/customer.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package models; 4 | option go_package = ".;models"; 5 | 6 | message Customer { 7 | string id = 1; 8 | string name = 2; 9 | string email = 3; 10 | } 11 | -------------------------------------------------------------------------------- /3-proto2-vs-proto3/protos/payment.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | 3 | package models; 4 | option go_package = ".;models"; 5 | 6 | message Payment { 7 | optional string payment_id = 1 [default = "p1"]; ; 8 | optional int32 amount = 2 [default = 57]; ; 9 | } 10 | -------------------------------------------------------------------------------- /3-proto2-vs-proto3/protos/order.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package models; 4 | option go_package = ".;models"; 5 | 6 | import "protos/customer.proto"; 7 | 8 | message Order { 9 | string order_id = 1; 10 | Customer customer = 2; 11 | double amount = 3; 12 | } 13 | -------------------------------------------------------------------------------- /2-top-level-statements/protos/order.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package models; 4 | option go_package = ".;models"; 5 | 6 | import "protos/customer.proto"; 7 | 8 | message Order { 9 | string order_id = 1; 10 | Customer customer = 2; 11 | double amount = 3; 12 | } 13 | -------------------------------------------------------------------------------- /1-protobuf-vs-json/person.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | option go_package = ".;main"; 4 | 5 | message Person { 6 | string name = 1; 7 | int32 id = 2; 8 | string email = 3; 9 | string phone = 4; 10 | string address = 5; 11 | int32 age = 6; 12 | string gender = 7; 13 | string occupation = 8; 14 | string nationality = 9; 15 | string marital_status = 10; 16 | } 17 | -------------------------------------------------------------------------------- /3-proto2-vs-proto3/main_test.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "testing" 6 | 7 | "github.com/arpitbbhayani/protobuf/models" 8 | ) 9 | 10 | var order = models.Order{} 11 | var payment = models.Payment{} 12 | 13 | func TestDefaults(t *testing.T) { 14 | fmt.Println(order.OrderId) 15 | fmt.Println(order.Amount) 16 | fmt.Println(order.Customer) 17 | fmt.Println(payment.Amount, payment.GetAmount()) 18 | } 19 | -------------------------------------------------------------------------------- /2-top-level-statements/main_test.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "testing" 6 | 7 | "github.com/arpitbbhayani/protobuf/models" 8 | ) 9 | 10 | var order = models.Order{ 11 | OrderId: "o1", 12 | Amount: 100, 13 | Customer: &models.Customer{ 14 | Id: "1", 15 | Name: "Arpit Bhayani", 16 | Email: "arpit@bhayani.com", 17 | }, 18 | } 19 | 20 | func Test1(t *testing.T) { 21 | fmt.Println(&order) 22 | } 23 | -------------------------------------------------------------------------------- /4-enum/protos/order2.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | 3 | package models; 4 | option go_package = ".;models"; 5 | 6 | enum OrderStatus2 { 7 | ORDER_STATUS2_PENDING = 1; 8 | ORDER_STATUS2_PROCESSING = 2; 9 | ORDER_STATUS2_SHIPPED = 3; 10 | ORDER_STATUS2_DELIVERED = 4; 11 | } 12 | 13 | message Order2 { 14 | required string order_id = 1; 15 | required double amount = 2; 16 | required OrderStatus2 status = 3; 17 | } 18 | -------------------------------------------------------------------------------- /4-enum/protos/order3.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package models; 4 | option go_package = ".;models"; 5 | 6 | enum OrderStatus3 { 7 | // remove ORDER_STATUS3 prefixes and it gives a compile-time error 8 | ORDER_STATUS3_UNSPECIFIDED = 0; // remove this line and it gives a compile-time error 9 | ORDER_STATUS3_PENDING = 1; 10 | ORDER_STATUS3_PROCESSING = 2; 11 | ORDER_STATUS3_SHIPPED = 3; 12 | ORDER_STATUS3_DELIVERED = 4; 13 | } 14 | 15 | message Order3 { 16 | string order_id = 1; 17 | double amount = 2; 18 | OrderStatus3 status = 3; 19 | } 20 | -------------------------------------------------------------------------------- /4-enum/main_test.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "testing" 6 | 7 | "github.com/arpitbbhayani/protobuf/models" 8 | ) 9 | 10 | var order2 = models.Order2{} 11 | var order3 = models.Order3{} 12 | 13 | func TestDefaults(t *testing.T) { 14 | fmt.Println("default value when member accessed", order2.Status) 15 | fmt.Println("default value when called GetStatus", order2.GetStatus()) // Defauult 1st value 16 | order2.Status = models.OrderStatus2_ORDER_STATUS2_DELIVERED.Enum() 17 | fmt.Println("value after setting Status", order2.GetStatus()) 18 | fmt.Println("for proto3, default value", order3.Status) 19 | } 20 | -------------------------------------------------------------------------------- /4-enum/go.sum: -------------------------------------------------------------------------------- 1 | github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= 2 | github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= 3 | github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU= 4 | github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= 5 | golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= 6 | golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= 7 | google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= 8 | google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= 9 | -------------------------------------------------------------------------------- /1-protobuf-vs-json/go.sum: -------------------------------------------------------------------------------- 1 | github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= 2 | github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= 3 | github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU= 4 | github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= 5 | golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= 6 | golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= 7 | google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= 8 | google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= 9 | -------------------------------------------------------------------------------- /3-proto2-vs-proto3/go.sum: -------------------------------------------------------------------------------- 1 | github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= 2 | github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= 3 | github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU= 4 | github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= 5 | golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= 6 | golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= 7 | google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= 8 | google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= 9 | -------------------------------------------------------------------------------- /2-top-level-statements/go.sum: -------------------------------------------------------------------------------- 1 | github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= 2 | github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= 3 | github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU= 4 | github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= 5 | golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= 6 | golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= 7 | google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= 8 | google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= 9 | -------------------------------------------------------------------------------- /1-protobuf-vs-json/README.md: -------------------------------------------------------------------------------- 1 | ```sh 2 | protoc --go_out=. person.proto 3 | go test -v . -bench=. 4 | ``` 5 | 6 | ``` 7 | { 8 | "name": "Jane Doe", 9 | "id": 2, 10 | "email": "jane.doe@example.com", 11 | "phone": "123-456-7890", 12 | "address": "123 Main St, Anytown, USA", 13 | "age": 28, 14 | "gender": "Female", 15 | "occupation": "Engineer", 16 | "nationality": "American", 17 | "marital_status": "Single" 18 | } 19 | === RUN TestSizeComparison 20 | main_test.go:86: JSON size: 220 bytes 21 | main_test.go:87: Protobuf size: 113 bytes 22 | --- PASS: TestSizeComparison (0.00s) 23 | goos: linux 24 | goarch: amd64 25 | pkg: github.com/arpitbbhayani/protobuf 26 | cpu: AMD Ryzen 7 4800U with Radeon Graphics 27 | BenchmarkJSONSerialization 28 | BenchmarkJSONSerialization-16 847700 1821 ns/op 29 | BenchmarkJSONDeserialization 30 | BenchmarkJSONDeserialization-16 160700 6994 ns/op 31 | BenchmarkProtobufSerialization 32 | BenchmarkProtobufSerialization-16 2009774 707.7 ns/op 33 | BenchmarkProtobufDeserialization 34 | BenchmarkProtobufDeserialization-16 1000000 1531 ns/op 35 | ``` 36 | -------------------------------------------------------------------------------- /1-protobuf-vs-json/main_test.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "encoding/json" 5 | "fmt" 6 | "testing" 7 | 8 | "google.golang.org/protobuf/proto" 9 | ) 10 | 11 | var person = Person{ 12 | Name: "Jane Doe", 13 | Id: 2, 14 | Email: "jane.doe@example.com", 15 | Phone: "123-456-7890", 16 | Address: "123 Main St, Anytown, USA", 17 | Age: 28, 18 | Gender: "Female", 19 | Occupation: "Engineer", 20 | Nationality: "American", 21 | MaritalStatus: "Single", 22 | } 23 | 24 | func init() { 25 | v, _ := json.MarshalIndent(&person, "", " ") 26 | fmt.Println(string(v)) 27 | } 28 | 29 | func BenchmarkJSONSerialization(b *testing.B) { 30 | for i := 0; i < b.N; i++ { 31 | _, err := json.Marshal(&person) 32 | if err != nil { 33 | b.Error(err) 34 | } 35 | } 36 | } 37 | 38 | func BenchmarkJSONDeserialization(b *testing.B) { 39 | data, err := json.Marshal(&person) 40 | if err != nil { 41 | b.Error(err) 42 | } 43 | for i := 0; i < b.N; i++ { 44 | var p Person 45 | err := json.Unmarshal(data, &p) 46 | if err != nil { 47 | b.Error(err) 48 | } 49 | } 50 | } 51 | 52 | func BenchmarkProtobufSerialization(b *testing.B) { 53 | for i := 0; i < b.N; i++ { 54 | _, err := proto.Marshal(&person) 55 | if err != nil { 56 | b.Error(err) 57 | } 58 | } 59 | } 60 | 61 | func BenchmarkProtobufDeserialization(b *testing.B) { 62 | data, err := proto.Marshal(&person) 63 | if err != nil { 64 | b.Error(err) 65 | } 66 | for i := 0; i < b.N; i++ { 67 | var p Person 68 | err := proto.Unmarshal(data, &p) 69 | if err != nil { 70 | b.Error(err) 71 | } 72 | } 73 | } 74 | 75 | func TestSizeComparison(t *testing.T) { 76 | jsonData, err := json.Marshal(&person) 77 | if err != nil { 78 | t.Error(err) 79 | } 80 | 81 | protoData, err := proto.Marshal(&person) 82 | if err != nil { 83 | t.Error(err) 84 | } 85 | 86 | t.Logf("JSON size: %d bytes", len(jsonData)) 87 | t.Logf("Protobuf size: %d bytes", len(protoData)) 88 | } 89 | -------------------------------------------------------------------------------- /3-proto2-vs-proto3/models/customer.pb.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoc-gen-go. DO NOT EDIT. 2 | // versions: 3 | // protoc-gen-go v1.35.2 4 | // protoc v4.25.1 5 | // source: protos/customer.proto 6 | 7 | package models 8 | 9 | import ( 10 | protoreflect "google.golang.org/protobuf/reflect/protoreflect" 11 | protoimpl "google.golang.org/protobuf/runtime/protoimpl" 12 | reflect "reflect" 13 | sync "sync" 14 | ) 15 | 16 | const ( 17 | // Verify that this generated code is sufficiently up-to-date. 18 | _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) 19 | // Verify that runtime/protoimpl is sufficiently up-to-date. 20 | _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) 21 | ) 22 | 23 | type Customer struct { 24 | state protoimpl.MessageState 25 | sizeCache protoimpl.SizeCache 26 | unknownFields protoimpl.UnknownFields 27 | 28 | Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` 29 | Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` 30 | Email string `protobuf:"bytes,3,opt,name=email,proto3" json:"email,omitempty"` 31 | } 32 | 33 | func (x *Customer) Reset() { 34 | *x = Customer{} 35 | mi := &file_protos_customer_proto_msgTypes[0] 36 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 37 | ms.StoreMessageInfo(mi) 38 | } 39 | 40 | func (x *Customer) String() string { 41 | return protoimpl.X.MessageStringOf(x) 42 | } 43 | 44 | func (*Customer) ProtoMessage() {} 45 | 46 | func (x *Customer) ProtoReflect() protoreflect.Message { 47 | mi := &file_protos_customer_proto_msgTypes[0] 48 | if x != nil { 49 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 50 | if ms.LoadMessageInfo() == nil { 51 | ms.StoreMessageInfo(mi) 52 | } 53 | return ms 54 | } 55 | return mi.MessageOf(x) 56 | } 57 | 58 | // Deprecated: Use Customer.ProtoReflect.Descriptor instead. 59 | func (*Customer) Descriptor() ([]byte, []int) { 60 | return file_protos_customer_proto_rawDescGZIP(), []int{0} 61 | } 62 | 63 | func (x *Customer) GetId() string { 64 | if x != nil { 65 | return x.Id 66 | } 67 | return "" 68 | } 69 | 70 | func (x *Customer) GetName() string { 71 | if x != nil { 72 | return x.Name 73 | } 74 | return "" 75 | } 76 | 77 | func (x *Customer) GetEmail() string { 78 | if x != nil { 79 | return x.Email 80 | } 81 | return "" 82 | } 83 | 84 | var File_protos_customer_proto protoreflect.FileDescriptor 85 | 86 | var file_protos_customer_proto_rawDesc = []byte{ 87 | 0x0a, 0x15, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x73, 0x2f, 0x63, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x65, 88 | 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x06, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x73, 0x22, 89 | 0x44, 0x0a, 0x08, 0x43, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x65, 0x72, 0x12, 0x0e, 0x0a, 0x02, 0x69, 90 | 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 91 | 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 92 | 0x14, 0x0a, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 93 | 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x42, 0x0a, 0x5a, 0x08, 0x2e, 0x3b, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 94 | 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, 95 | } 96 | 97 | var ( 98 | file_protos_customer_proto_rawDescOnce sync.Once 99 | file_protos_customer_proto_rawDescData = file_protos_customer_proto_rawDesc 100 | ) 101 | 102 | func file_protos_customer_proto_rawDescGZIP() []byte { 103 | file_protos_customer_proto_rawDescOnce.Do(func() { 104 | file_protos_customer_proto_rawDescData = protoimpl.X.CompressGZIP(file_protos_customer_proto_rawDescData) 105 | }) 106 | return file_protos_customer_proto_rawDescData 107 | } 108 | 109 | var file_protos_customer_proto_msgTypes = make([]protoimpl.MessageInfo, 1) 110 | var file_protos_customer_proto_goTypes = []any{ 111 | (*Customer)(nil), // 0: models.Customer 112 | } 113 | var file_protos_customer_proto_depIdxs = []int32{ 114 | 0, // [0:0] is the sub-list for method output_type 115 | 0, // [0:0] is the sub-list for method input_type 116 | 0, // [0:0] is the sub-list for extension type_name 117 | 0, // [0:0] is the sub-list for extension extendee 118 | 0, // [0:0] is the sub-list for field type_name 119 | } 120 | 121 | func init() { file_protos_customer_proto_init() } 122 | func file_protos_customer_proto_init() { 123 | if File_protos_customer_proto != nil { 124 | return 125 | } 126 | type x struct{} 127 | out := protoimpl.TypeBuilder{ 128 | File: protoimpl.DescBuilder{ 129 | GoPackagePath: reflect.TypeOf(x{}).PkgPath(), 130 | RawDescriptor: file_protos_customer_proto_rawDesc, 131 | NumEnums: 0, 132 | NumMessages: 1, 133 | NumExtensions: 0, 134 | NumServices: 0, 135 | }, 136 | GoTypes: file_protos_customer_proto_goTypes, 137 | DependencyIndexes: file_protos_customer_proto_depIdxs, 138 | MessageInfos: file_protos_customer_proto_msgTypes, 139 | }.Build() 140 | File_protos_customer_proto = out.File 141 | file_protos_customer_proto_rawDesc = nil 142 | file_protos_customer_proto_goTypes = nil 143 | file_protos_customer_proto_depIdxs = nil 144 | } 145 | -------------------------------------------------------------------------------- /2-top-level-statements/models/customer.pb.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoc-gen-go. DO NOT EDIT. 2 | // versions: 3 | // protoc-gen-go v1.35.2 4 | // protoc v4.25.1 5 | // source: protos/customer.proto 6 | 7 | package models 8 | 9 | import ( 10 | protoreflect "google.golang.org/protobuf/reflect/protoreflect" 11 | protoimpl "google.golang.org/protobuf/runtime/protoimpl" 12 | reflect "reflect" 13 | sync "sync" 14 | ) 15 | 16 | const ( 17 | // Verify that this generated code is sufficiently up-to-date. 18 | _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) 19 | // Verify that runtime/protoimpl is sufficiently up-to-date. 20 | _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) 21 | ) 22 | 23 | type Customer struct { 24 | state protoimpl.MessageState 25 | sizeCache protoimpl.SizeCache 26 | unknownFields protoimpl.UnknownFields 27 | 28 | Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` 29 | Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` 30 | Email string `protobuf:"bytes,3,opt,name=email,proto3" json:"email,omitempty"` 31 | } 32 | 33 | func (x *Customer) Reset() { 34 | *x = Customer{} 35 | mi := &file_protos_customer_proto_msgTypes[0] 36 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 37 | ms.StoreMessageInfo(mi) 38 | } 39 | 40 | func (x *Customer) String() string { 41 | return protoimpl.X.MessageStringOf(x) 42 | } 43 | 44 | func (*Customer) ProtoMessage() {} 45 | 46 | func (x *Customer) ProtoReflect() protoreflect.Message { 47 | mi := &file_protos_customer_proto_msgTypes[0] 48 | if x != nil { 49 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 50 | if ms.LoadMessageInfo() == nil { 51 | ms.StoreMessageInfo(mi) 52 | } 53 | return ms 54 | } 55 | return mi.MessageOf(x) 56 | } 57 | 58 | // Deprecated: Use Customer.ProtoReflect.Descriptor instead. 59 | func (*Customer) Descriptor() ([]byte, []int) { 60 | return file_protos_customer_proto_rawDescGZIP(), []int{0} 61 | } 62 | 63 | func (x *Customer) GetId() string { 64 | if x != nil { 65 | return x.Id 66 | } 67 | return "" 68 | } 69 | 70 | func (x *Customer) GetName() string { 71 | if x != nil { 72 | return x.Name 73 | } 74 | return "" 75 | } 76 | 77 | func (x *Customer) GetEmail() string { 78 | if x != nil { 79 | return x.Email 80 | } 81 | return "" 82 | } 83 | 84 | var File_protos_customer_proto protoreflect.FileDescriptor 85 | 86 | var file_protos_customer_proto_rawDesc = []byte{ 87 | 0x0a, 0x15, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x73, 0x2f, 0x63, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x65, 88 | 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x06, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x73, 0x22, 89 | 0x44, 0x0a, 0x08, 0x43, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x65, 0x72, 0x12, 0x0e, 0x0a, 0x02, 0x69, 90 | 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 91 | 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 92 | 0x14, 0x0a, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 93 | 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x42, 0x0a, 0x5a, 0x08, 0x2e, 0x3b, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 94 | 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, 95 | } 96 | 97 | var ( 98 | file_protos_customer_proto_rawDescOnce sync.Once 99 | file_protos_customer_proto_rawDescData = file_protos_customer_proto_rawDesc 100 | ) 101 | 102 | func file_protos_customer_proto_rawDescGZIP() []byte { 103 | file_protos_customer_proto_rawDescOnce.Do(func() { 104 | file_protos_customer_proto_rawDescData = protoimpl.X.CompressGZIP(file_protos_customer_proto_rawDescData) 105 | }) 106 | return file_protos_customer_proto_rawDescData 107 | } 108 | 109 | var file_protos_customer_proto_msgTypes = make([]protoimpl.MessageInfo, 1) 110 | var file_protos_customer_proto_goTypes = []any{ 111 | (*Customer)(nil), // 0: models.Customer 112 | } 113 | var file_protos_customer_proto_depIdxs = []int32{ 114 | 0, // [0:0] is the sub-list for method output_type 115 | 0, // [0:0] is the sub-list for method input_type 116 | 0, // [0:0] is the sub-list for extension type_name 117 | 0, // [0:0] is the sub-list for extension extendee 118 | 0, // [0:0] is the sub-list for field type_name 119 | } 120 | 121 | func init() { file_protos_customer_proto_init() } 122 | func file_protos_customer_proto_init() { 123 | if File_protos_customer_proto != nil { 124 | return 125 | } 126 | type x struct{} 127 | out := protoimpl.TypeBuilder{ 128 | File: protoimpl.DescBuilder{ 129 | GoPackagePath: reflect.TypeOf(x{}).PkgPath(), 130 | RawDescriptor: file_protos_customer_proto_rawDesc, 131 | NumEnums: 0, 132 | NumMessages: 1, 133 | NumExtensions: 0, 134 | NumServices: 0, 135 | }, 136 | GoTypes: file_protos_customer_proto_goTypes, 137 | DependencyIndexes: file_protos_customer_proto_depIdxs, 138 | MessageInfos: file_protos_customer_proto_msgTypes, 139 | }.Build() 140 | File_protos_customer_proto = out.File 141 | file_protos_customer_proto_rawDesc = nil 142 | file_protos_customer_proto_goTypes = nil 143 | file_protos_customer_proto_depIdxs = nil 144 | } 145 | -------------------------------------------------------------------------------- /3-proto2-vs-proto3/models/payment.pb.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoc-gen-go. DO NOT EDIT. 2 | // versions: 3 | // protoc-gen-go v1.35.2 4 | // protoc v4.25.1 5 | // source: protos/payment.proto 6 | 7 | package models 8 | 9 | import ( 10 | protoreflect "google.golang.org/protobuf/reflect/protoreflect" 11 | protoimpl "google.golang.org/protobuf/runtime/protoimpl" 12 | reflect "reflect" 13 | sync "sync" 14 | ) 15 | 16 | const ( 17 | // Verify that this generated code is sufficiently up-to-date. 18 | _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) 19 | // Verify that runtime/protoimpl is sufficiently up-to-date. 20 | _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) 21 | ) 22 | 23 | type Payment struct { 24 | state protoimpl.MessageState 25 | sizeCache protoimpl.SizeCache 26 | unknownFields protoimpl.UnknownFields 27 | 28 | PaymentId *string `protobuf:"bytes,1,opt,name=payment_id,json=paymentId,def=p1" json:"payment_id,omitempty"` 29 | Amount *int32 `protobuf:"varint,2,opt,name=amount,def=57" json:"amount,omitempty"` 30 | } 31 | 32 | // Default values for Payment fields. 33 | const ( 34 | Default_Payment_PaymentId = string("p1") 35 | Default_Payment_Amount = int32(57) 36 | ) 37 | 38 | func (x *Payment) Reset() { 39 | *x = Payment{} 40 | mi := &file_protos_payment_proto_msgTypes[0] 41 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 42 | ms.StoreMessageInfo(mi) 43 | } 44 | 45 | func (x *Payment) String() string { 46 | return protoimpl.X.MessageStringOf(x) 47 | } 48 | 49 | func (*Payment) ProtoMessage() {} 50 | 51 | func (x *Payment) ProtoReflect() protoreflect.Message { 52 | mi := &file_protos_payment_proto_msgTypes[0] 53 | if x != nil { 54 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 55 | if ms.LoadMessageInfo() == nil { 56 | ms.StoreMessageInfo(mi) 57 | } 58 | return ms 59 | } 60 | return mi.MessageOf(x) 61 | } 62 | 63 | // Deprecated: Use Payment.ProtoReflect.Descriptor instead. 64 | func (*Payment) Descriptor() ([]byte, []int) { 65 | return file_protos_payment_proto_rawDescGZIP(), []int{0} 66 | } 67 | 68 | func (x *Payment) GetPaymentId() string { 69 | if x != nil && x.PaymentId != nil { 70 | return *x.PaymentId 71 | } 72 | return Default_Payment_PaymentId 73 | } 74 | 75 | func (x *Payment) GetAmount() int32 { 76 | if x != nil && x.Amount != nil { 77 | return *x.Amount 78 | } 79 | return Default_Payment_Amount 80 | } 81 | 82 | var File_protos_payment_proto protoreflect.FileDescriptor 83 | 84 | var file_protos_payment_proto_rawDesc = []byte{ 85 | 0x0a, 0x14, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x73, 0x2f, 0x70, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 86 | 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x06, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x73, 0x22, 0x48, 87 | 0x0a, 0x07, 0x50, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x21, 0x0a, 0x0a, 0x70, 0x61, 0x79, 88 | 0x6d, 0x65, 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x3a, 0x02, 0x70, 89 | 0x31, 0x52, 0x09, 0x70, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x49, 0x64, 0x12, 0x1a, 0x0a, 0x06, 90 | 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x3a, 0x02, 0x35, 0x37, 91 | 0x52, 0x06, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x42, 0x0a, 0x5a, 0x08, 0x2e, 0x3b, 0x6d, 0x6f, 92 | 0x64, 0x65, 0x6c, 0x73, 93 | } 94 | 95 | var ( 96 | file_protos_payment_proto_rawDescOnce sync.Once 97 | file_protos_payment_proto_rawDescData = file_protos_payment_proto_rawDesc 98 | ) 99 | 100 | func file_protos_payment_proto_rawDescGZIP() []byte { 101 | file_protos_payment_proto_rawDescOnce.Do(func() { 102 | file_protos_payment_proto_rawDescData = protoimpl.X.CompressGZIP(file_protos_payment_proto_rawDescData) 103 | }) 104 | return file_protos_payment_proto_rawDescData 105 | } 106 | 107 | var file_protos_payment_proto_msgTypes = make([]protoimpl.MessageInfo, 1) 108 | var file_protos_payment_proto_goTypes = []any{ 109 | (*Payment)(nil), // 0: models.Payment 110 | } 111 | var file_protos_payment_proto_depIdxs = []int32{ 112 | 0, // [0:0] is the sub-list for method output_type 113 | 0, // [0:0] is the sub-list for method input_type 114 | 0, // [0:0] is the sub-list for extension type_name 115 | 0, // [0:0] is the sub-list for extension extendee 116 | 0, // [0:0] is the sub-list for field type_name 117 | } 118 | 119 | func init() { file_protos_payment_proto_init() } 120 | func file_protos_payment_proto_init() { 121 | if File_protos_payment_proto != nil { 122 | return 123 | } 124 | type x struct{} 125 | out := protoimpl.TypeBuilder{ 126 | File: protoimpl.DescBuilder{ 127 | GoPackagePath: reflect.TypeOf(x{}).PkgPath(), 128 | RawDescriptor: file_protos_payment_proto_rawDesc, 129 | NumEnums: 0, 130 | NumMessages: 1, 131 | NumExtensions: 0, 132 | NumServices: 0, 133 | }, 134 | GoTypes: file_protos_payment_proto_goTypes, 135 | DependencyIndexes: file_protos_payment_proto_depIdxs, 136 | MessageInfos: file_protos_payment_proto_msgTypes, 137 | }.Build() 138 | File_protos_payment_proto = out.File 139 | file_protos_payment_proto_rawDesc = nil 140 | file_protos_payment_proto_goTypes = nil 141 | file_protos_payment_proto_depIdxs = nil 142 | } 143 | -------------------------------------------------------------------------------- /3-proto2-vs-proto3/models/order.pb.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoc-gen-go. DO NOT EDIT. 2 | // versions: 3 | // protoc-gen-go v1.35.2 4 | // protoc v4.25.1 5 | // source: protos/order.proto 6 | 7 | package models 8 | 9 | import ( 10 | protoreflect "google.golang.org/protobuf/reflect/protoreflect" 11 | protoimpl "google.golang.org/protobuf/runtime/protoimpl" 12 | reflect "reflect" 13 | sync "sync" 14 | ) 15 | 16 | const ( 17 | // Verify that this generated code is sufficiently up-to-date. 18 | _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) 19 | // Verify that runtime/protoimpl is sufficiently up-to-date. 20 | _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) 21 | ) 22 | 23 | type Order struct { 24 | state protoimpl.MessageState 25 | sizeCache protoimpl.SizeCache 26 | unknownFields protoimpl.UnknownFields 27 | 28 | OrderId string `protobuf:"bytes,1,opt,name=order_id,json=orderId,proto3" json:"order_id,omitempty"` 29 | Customer *Customer `protobuf:"bytes,2,opt,name=customer,proto3" json:"customer,omitempty"` 30 | Amount float64 `protobuf:"fixed64,3,opt,name=amount,proto3" json:"amount,omitempty"` 31 | } 32 | 33 | func (x *Order) Reset() { 34 | *x = Order{} 35 | mi := &file_protos_order_proto_msgTypes[0] 36 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 37 | ms.StoreMessageInfo(mi) 38 | } 39 | 40 | func (x *Order) String() string { 41 | return protoimpl.X.MessageStringOf(x) 42 | } 43 | 44 | func (*Order) ProtoMessage() {} 45 | 46 | func (x *Order) ProtoReflect() protoreflect.Message { 47 | mi := &file_protos_order_proto_msgTypes[0] 48 | if x != nil { 49 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 50 | if ms.LoadMessageInfo() == nil { 51 | ms.StoreMessageInfo(mi) 52 | } 53 | return ms 54 | } 55 | return mi.MessageOf(x) 56 | } 57 | 58 | // Deprecated: Use Order.ProtoReflect.Descriptor instead. 59 | func (*Order) Descriptor() ([]byte, []int) { 60 | return file_protos_order_proto_rawDescGZIP(), []int{0} 61 | } 62 | 63 | func (x *Order) GetOrderId() string { 64 | if x != nil { 65 | return x.OrderId 66 | } 67 | return "" 68 | } 69 | 70 | func (x *Order) GetCustomer() *Customer { 71 | if x != nil { 72 | return x.Customer 73 | } 74 | return nil 75 | } 76 | 77 | func (x *Order) GetAmount() float64 { 78 | if x != nil { 79 | return x.Amount 80 | } 81 | return 0 82 | } 83 | 84 | var File_protos_order_proto protoreflect.FileDescriptor 85 | 86 | var file_protos_order_proto_rawDesc = []byte{ 87 | 0x0a, 0x12, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x73, 0x2f, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x2e, 0x70, 88 | 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x06, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x73, 0x1a, 0x15, 0x70, 0x72, 89 | 0x6f, 0x74, 0x6f, 0x73, 0x2f, 0x63, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x65, 0x72, 0x2e, 0x70, 0x72, 90 | 0x6f, 0x74, 0x6f, 0x22, 0x68, 0x0a, 0x05, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x12, 0x19, 0x0a, 0x08, 91 | 0x6f, 0x72, 0x64, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 92 | 0x6f, 0x72, 0x64, 0x65, 0x72, 0x49, 0x64, 0x12, 0x2c, 0x0a, 0x08, 0x63, 0x75, 0x73, 0x74, 0x6f, 93 | 0x6d, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x6d, 0x6f, 0x64, 0x65, 94 | 0x6c, 0x73, 0x2e, 0x43, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x65, 0x72, 0x52, 0x08, 0x63, 0x75, 0x73, 95 | 0x74, 0x6f, 0x6d, 0x65, 0x72, 0x12, 0x16, 0x0a, 0x06, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x18, 96 | 0x03, 0x20, 0x01, 0x28, 0x01, 0x52, 0x06, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x42, 0x0a, 0x5a, 97 | 0x08, 0x2e, 0x3b, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 98 | 0x33, 99 | } 100 | 101 | var ( 102 | file_protos_order_proto_rawDescOnce sync.Once 103 | file_protos_order_proto_rawDescData = file_protos_order_proto_rawDesc 104 | ) 105 | 106 | func file_protos_order_proto_rawDescGZIP() []byte { 107 | file_protos_order_proto_rawDescOnce.Do(func() { 108 | file_protos_order_proto_rawDescData = protoimpl.X.CompressGZIP(file_protos_order_proto_rawDescData) 109 | }) 110 | return file_protos_order_proto_rawDescData 111 | } 112 | 113 | var file_protos_order_proto_msgTypes = make([]protoimpl.MessageInfo, 1) 114 | var file_protos_order_proto_goTypes = []any{ 115 | (*Order)(nil), // 0: models.Order 116 | (*Customer)(nil), // 1: models.Customer 117 | } 118 | var file_protos_order_proto_depIdxs = []int32{ 119 | 1, // 0: models.Order.customer:type_name -> models.Customer 120 | 1, // [1:1] is the sub-list for method output_type 121 | 1, // [1:1] is the sub-list for method input_type 122 | 1, // [1:1] is the sub-list for extension type_name 123 | 1, // [1:1] is the sub-list for extension extendee 124 | 0, // [0:1] is the sub-list for field type_name 125 | } 126 | 127 | func init() { file_protos_order_proto_init() } 128 | func file_protos_order_proto_init() { 129 | if File_protos_order_proto != nil { 130 | return 131 | } 132 | file_protos_customer_proto_init() 133 | type x struct{} 134 | out := protoimpl.TypeBuilder{ 135 | File: protoimpl.DescBuilder{ 136 | GoPackagePath: reflect.TypeOf(x{}).PkgPath(), 137 | RawDescriptor: file_protos_order_proto_rawDesc, 138 | NumEnums: 0, 139 | NumMessages: 1, 140 | NumExtensions: 0, 141 | NumServices: 0, 142 | }, 143 | GoTypes: file_protos_order_proto_goTypes, 144 | DependencyIndexes: file_protos_order_proto_depIdxs, 145 | MessageInfos: file_protos_order_proto_msgTypes, 146 | }.Build() 147 | File_protos_order_proto = out.File 148 | file_protos_order_proto_rawDesc = nil 149 | file_protos_order_proto_goTypes = nil 150 | file_protos_order_proto_depIdxs = nil 151 | } 152 | -------------------------------------------------------------------------------- /2-top-level-statements/models/order.pb.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoc-gen-go. DO NOT EDIT. 2 | // versions: 3 | // protoc-gen-go v1.35.2 4 | // protoc v4.25.1 5 | // source: protos/order.proto 6 | 7 | package models 8 | 9 | import ( 10 | protoreflect "google.golang.org/protobuf/reflect/protoreflect" 11 | protoimpl "google.golang.org/protobuf/runtime/protoimpl" 12 | reflect "reflect" 13 | sync "sync" 14 | ) 15 | 16 | const ( 17 | // Verify that this generated code is sufficiently up-to-date. 18 | _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) 19 | // Verify that runtime/protoimpl is sufficiently up-to-date. 20 | _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) 21 | ) 22 | 23 | type Order struct { 24 | state protoimpl.MessageState 25 | sizeCache protoimpl.SizeCache 26 | unknownFields protoimpl.UnknownFields 27 | 28 | OrderId string `protobuf:"bytes,1,opt,name=order_id,json=orderId,proto3" json:"order_id,omitempty"` 29 | Customer *Customer `protobuf:"bytes,2,opt,name=customer,proto3" json:"customer,omitempty"` 30 | Amount float64 `protobuf:"fixed64,3,opt,name=amount,proto3" json:"amount,omitempty"` 31 | } 32 | 33 | func (x *Order) Reset() { 34 | *x = Order{} 35 | mi := &file_protos_order_proto_msgTypes[0] 36 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 37 | ms.StoreMessageInfo(mi) 38 | } 39 | 40 | func (x *Order) String() string { 41 | return protoimpl.X.MessageStringOf(x) 42 | } 43 | 44 | func (*Order) ProtoMessage() {} 45 | 46 | func (x *Order) ProtoReflect() protoreflect.Message { 47 | mi := &file_protos_order_proto_msgTypes[0] 48 | if x != nil { 49 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 50 | if ms.LoadMessageInfo() == nil { 51 | ms.StoreMessageInfo(mi) 52 | } 53 | return ms 54 | } 55 | return mi.MessageOf(x) 56 | } 57 | 58 | // Deprecated: Use Order.ProtoReflect.Descriptor instead. 59 | func (*Order) Descriptor() ([]byte, []int) { 60 | return file_protos_order_proto_rawDescGZIP(), []int{0} 61 | } 62 | 63 | func (x *Order) GetOrderId() string { 64 | if x != nil { 65 | return x.OrderId 66 | } 67 | return "" 68 | } 69 | 70 | func (x *Order) GetCustomer() *Customer { 71 | if x != nil { 72 | return x.Customer 73 | } 74 | return nil 75 | } 76 | 77 | func (x *Order) GetAmount() float64 { 78 | if x != nil { 79 | return x.Amount 80 | } 81 | return 0 82 | } 83 | 84 | var File_protos_order_proto protoreflect.FileDescriptor 85 | 86 | var file_protos_order_proto_rawDesc = []byte{ 87 | 0x0a, 0x12, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x73, 0x2f, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x2e, 0x70, 88 | 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x06, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x73, 0x1a, 0x15, 0x70, 0x72, 89 | 0x6f, 0x74, 0x6f, 0x73, 0x2f, 0x63, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x65, 0x72, 0x2e, 0x70, 0x72, 90 | 0x6f, 0x74, 0x6f, 0x22, 0x68, 0x0a, 0x05, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x12, 0x19, 0x0a, 0x08, 91 | 0x6f, 0x72, 0x64, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 92 | 0x6f, 0x72, 0x64, 0x65, 0x72, 0x49, 0x64, 0x12, 0x2c, 0x0a, 0x08, 0x63, 0x75, 0x73, 0x74, 0x6f, 93 | 0x6d, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x6d, 0x6f, 0x64, 0x65, 94 | 0x6c, 0x73, 0x2e, 0x43, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x65, 0x72, 0x52, 0x08, 0x63, 0x75, 0x73, 95 | 0x74, 0x6f, 0x6d, 0x65, 0x72, 0x12, 0x16, 0x0a, 0x06, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x18, 96 | 0x03, 0x20, 0x01, 0x28, 0x01, 0x52, 0x06, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x42, 0x0a, 0x5a, 97 | 0x08, 0x2e, 0x3b, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 98 | 0x33, 99 | } 100 | 101 | var ( 102 | file_protos_order_proto_rawDescOnce sync.Once 103 | file_protos_order_proto_rawDescData = file_protos_order_proto_rawDesc 104 | ) 105 | 106 | func file_protos_order_proto_rawDescGZIP() []byte { 107 | file_protos_order_proto_rawDescOnce.Do(func() { 108 | file_protos_order_proto_rawDescData = protoimpl.X.CompressGZIP(file_protos_order_proto_rawDescData) 109 | }) 110 | return file_protos_order_proto_rawDescData 111 | } 112 | 113 | var file_protos_order_proto_msgTypes = make([]protoimpl.MessageInfo, 1) 114 | var file_protos_order_proto_goTypes = []any{ 115 | (*Order)(nil), // 0: models.Order 116 | (*Customer)(nil), // 1: models.Customer 117 | } 118 | var file_protos_order_proto_depIdxs = []int32{ 119 | 1, // 0: models.Order.customer:type_name -> models.Customer 120 | 1, // [1:1] is the sub-list for method output_type 121 | 1, // [1:1] is the sub-list for method input_type 122 | 1, // [1:1] is the sub-list for extension type_name 123 | 1, // [1:1] is the sub-list for extension extendee 124 | 0, // [0:1] is the sub-list for field type_name 125 | } 126 | 127 | func init() { file_protos_order_proto_init() } 128 | func file_protos_order_proto_init() { 129 | if File_protos_order_proto != nil { 130 | return 131 | } 132 | file_protos_customer_proto_init() 133 | type x struct{} 134 | out := protoimpl.TypeBuilder{ 135 | File: protoimpl.DescBuilder{ 136 | GoPackagePath: reflect.TypeOf(x{}).PkgPath(), 137 | RawDescriptor: file_protos_order_proto_rawDesc, 138 | NumEnums: 0, 139 | NumMessages: 1, 140 | NumExtensions: 0, 141 | NumServices: 0, 142 | }, 143 | GoTypes: file_protos_order_proto_goTypes, 144 | DependencyIndexes: file_protos_order_proto_depIdxs, 145 | MessageInfos: file_protos_order_proto_msgTypes, 146 | }.Build() 147 | File_protos_order_proto = out.File 148 | file_protos_order_proto_rawDesc = nil 149 | file_protos_order_proto_goTypes = nil 150 | file_protos_order_proto_depIdxs = nil 151 | } 152 | -------------------------------------------------------------------------------- /1-protobuf-vs-json/person.pb.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoc-gen-go. DO NOT EDIT. 2 | // versions: 3 | // protoc-gen-go v1.35.2 4 | // protoc v4.25.1 5 | // source: person.proto 6 | 7 | package main 8 | 9 | import ( 10 | protoreflect "google.golang.org/protobuf/reflect/protoreflect" 11 | protoimpl "google.golang.org/protobuf/runtime/protoimpl" 12 | reflect "reflect" 13 | sync "sync" 14 | ) 15 | 16 | const ( 17 | // Verify that this generated code is sufficiently up-to-date. 18 | _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) 19 | // Verify that runtime/protoimpl is sufficiently up-to-date. 20 | _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) 21 | ) 22 | 23 | type Person struct { 24 | state protoimpl.MessageState 25 | sizeCache protoimpl.SizeCache 26 | unknownFields protoimpl.UnknownFields 27 | 28 | Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` 29 | Id int32 `protobuf:"varint,2,opt,name=id,proto3" json:"id,omitempty"` 30 | Email string `protobuf:"bytes,3,opt,name=email,proto3" json:"email,omitempty"` 31 | Phone string `protobuf:"bytes,4,opt,name=phone,proto3" json:"phone,omitempty"` 32 | Address string `protobuf:"bytes,5,opt,name=address,proto3" json:"address,omitempty"` 33 | Age int32 `protobuf:"varint,6,opt,name=age,proto3" json:"age,omitempty"` 34 | Gender string `protobuf:"bytes,7,opt,name=gender,proto3" json:"gender,omitempty"` 35 | Occupation string `protobuf:"bytes,8,opt,name=occupation,proto3" json:"occupation,omitempty"` 36 | Nationality string `protobuf:"bytes,9,opt,name=nationality,proto3" json:"nationality,omitempty"` 37 | MaritalStatus string `protobuf:"bytes,10,opt,name=marital_status,json=maritalStatus,proto3" json:"marital_status,omitempty"` 38 | } 39 | 40 | func (x *Person) Reset() { 41 | *x = Person{} 42 | mi := &file_person_proto_msgTypes[0] 43 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 44 | ms.StoreMessageInfo(mi) 45 | } 46 | 47 | func (x *Person) String() string { 48 | return protoimpl.X.MessageStringOf(x) 49 | } 50 | 51 | func (*Person) ProtoMessage() {} 52 | 53 | func (x *Person) ProtoReflect() protoreflect.Message { 54 | mi := &file_person_proto_msgTypes[0] 55 | if x != nil { 56 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 57 | if ms.LoadMessageInfo() == nil { 58 | ms.StoreMessageInfo(mi) 59 | } 60 | return ms 61 | } 62 | return mi.MessageOf(x) 63 | } 64 | 65 | // Deprecated: Use Person.ProtoReflect.Descriptor instead. 66 | func (*Person) Descriptor() ([]byte, []int) { 67 | return file_person_proto_rawDescGZIP(), []int{0} 68 | } 69 | 70 | func (x *Person) GetName() string { 71 | if x != nil { 72 | return x.Name 73 | } 74 | return "" 75 | } 76 | 77 | func (x *Person) GetId() int32 { 78 | if x != nil { 79 | return x.Id 80 | } 81 | return 0 82 | } 83 | 84 | func (x *Person) GetEmail() string { 85 | if x != nil { 86 | return x.Email 87 | } 88 | return "" 89 | } 90 | 91 | func (x *Person) GetPhone() string { 92 | if x != nil { 93 | return x.Phone 94 | } 95 | return "" 96 | } 97 | 98 | func (x *Person) GetAddress() string { 99 | if x != nil { 100 | return x.Address 101 | } 102 | return "" 103 | } 104 | 105 | func (x *Person) GetAge() int32 { 106 | if x != nil { 107 | return x.Age 108 | } 109 | return 0 110 | } 111 | 112 | func (x *Person) GetGender() string { 113 | if x != nil { 114 | return x.Gender 115 | } 116 | return "" 117 | } 118 | 119 | func (x *Person) GetOccupation() string { 120 | if x != nil { 121 | return x.Occupation 122 | } 123 | return "" 124 | } 125 | 126 | func (x *Person) GetNationality() string { 127 | if x != nil { 128 | return x.Nationality 129 | } 130 | return "" 131 | } 132 | 133 | func (x *Person) GetMaritalStatus() string { 134 | if x != nil { 135 | return x.MaritalStatus 136 | } 137 | return "" 138 | } 139 | 140 | var File_person_proto protoreflect.FileDescriptor 141 | 142 | var file_person_proto_rawDesc = []byte{ 143 | 0x0a, 0x0c, 0x70, 0x65, 0x72, 0x73, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x85, 144 | 0x02, 0x0a, 0x06, 0x50, 0x65, 0x72, 0x73, 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 145 | 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x0e, 0x0a, 146 | 0x02, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x02, 0x69, 0x64, 0x12, 0x14, 0x0a, 147 | 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x6d, 148 | 0x61, 0x69, 0x6c, 0x12, 0x14, 0x0a, 0x05, 0x70, 0x68, 0x6f, 0x6e, 0x65, 0x18, 0x04, 0x20, 0x01, 149 | 0x28, 0x09, 0x52, 0x05, 0x70, 0x68, 0x6f, 0x6e, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x61, 0x64, 0x64, 150 | 0x72, 0x65, 0x73, 0x73, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x61, 0x64, 0x64, 0x72, 151 | 0x65, 0x73, 0x73, 0x12, 0x10, 0x0a, 0x03, 0x61, 0x67, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x05, 152 | 0x52, 0x03, 0x61, 0x67, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x67, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x18, 153 | 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x67, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x12, 0x1e, 0x0a, 154 | 0x0a, 0x6f, 0x63, 0x63, 0x75, 0x70, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x08, 0x20, 0x01, 0x28, 155 | 0x09, 0x52, 0x0a, 0x6f, 0x63, 0x63, 0x75, 0x70, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x20, 0x0a, 156 | 0x0b, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x69, 0x74, 0x79, 0x18, 0x09, 0x20, 0x01, 157 | 0x28, 0x09, 0x52, 0x0b, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x69, 0x74, 0x79, 0x12, 158 | 0x25, 0x0a, 0x0e, 0x6d, 0x61, 0x72, 0x69, 0x74, 0x61, 0x6c, 0x5f, 0x73, 0x74, 0x61, 0x74, 0x75, 159 | 0x73, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x6d, 0x61, 0x72, 0x69, 0x74, 0x61, 0x6c, 160 | 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x42, 0x08, 0x5a, 0x06, 0x2e, 0x3b, 0x6d, 0x61, 0x69, 0x6e, 161 | 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, 162 | } 163 | 164 | var ( 165 | file_person_proto_rawDescOnce sync.Once 166 | file_person_proto_rawDescData = file_person_proto_rawDesc 167 | ) 168 | 169 | func file_person_proto_rawDescGZIP() []byte { 170 | file_person_proto_rawDescOnce.Do(func() { 171 | file_person_proto_rawDescData = protoimpl.X.CompressGZIP(file_person_proto_rawDescData) 172 | }) 173 | return file_person_proto_rawDescData 174 | } 175 | 176 | var file_person_proto_msgTypes = make([]protoimpl.MessageInfo, 1) 177 | var file_person_proto_goTypes = []any{ 178 | (*Person)(nil), // 0: Person 179 | } 180 | var file_person_proto_depIdxs = []int32{ 181 | 0, // [0:0] is the sub-list for method output_type 182 | 0, // [0:0] is the sub-list for method input_type 183 | 0, // [0:0] is the sub-list for extension type_name 184 | 0, // [0:0] is the sub-list for extension extendee 185 | 0, // [0:0] is the sub-list for field type_name 186 | } 187 | 188 | func init() { file_person_proto_init() } 189 | func file_person_proto_init() { 190 | if File_person_proto != nil { 191 | return 192 | } 193 | type x struct{} 194 | out := protoimpl.TypeBuilder{ 195 | File: protoimpl.DescBuilder{ 196 | GoPackagePath: reflect.TypeOf(x{}).PkgPath(), 197 | RawDescriptor: file_person_proto_rawDesc, 198 | NumEnums: 0, 199 | NumMessages: 1, 200 | NumExtensions: 0, 201 | NumServices: 0, 202 | }, 203 | GoTypes: file_person_proto_goTypes, 204 | DependencyIndexes: file_person_proto_depIdxs, 205 | MessageInfos: file_person_proto_msgTypes, 206 | }.Build() 207 | File_person_proto = out.File 208 | file_person_proto_rawDesc = nil 209 | file_person_proto_goTypes = nil 210 | file_person_proto_depIdxs = nil 211 | } 212 | -------------------------------------------------------------------------------- /4-enum/models/order2.pb.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoc-gen-go. DO NOT EDIT. 2 | // versions: 3 | // protoc-gen-go v1.35.2 4 | // protoc v4.25.1 5 | // source: protos/order2.proto 6 | 7 | package models 8 | 9 | import ( 10 | protoreflect "google.golang.org/protobuf/reflect/protoreflect" 11 | protoimpl "google.golang.org/protobuf/runtime/protoimpl" 12 | reflect "reflect" 13 | sync "sync" 14 | ) 15 | 16 | const ( 17 | // Verify that this generated code is sufficiently up-to-date. 18 | _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) 19 | // Verify that runtime/protoimpl is sufficiently up-to-date. 20 | _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) 21 | ) 22 | 23 | type OrderStatus2 int32 24 | 25 | const ( 26 | OrderStatus2_ORDER_STATUS2_PENDING OrderStatus2 = 1 27 | OrderStatus2_ORDER_STATUS2_PROCESSING OrderStatus2 = 2 28 | OrderStatus2_ORDER_STATUS2_SHIPPED OrderStatus2 = 3 29 | OrderStatus2_ORDER_STATUS2_DELIVERED OrderStatus2 = 4 30 | ) 31 | 32 | // Enum value maps for OrderStatus2. 33 | var ( 34 | OrderStatus2_name = map[int32]string{ 35 | 1: "ORDER_STATUS2_PENDING", 36 | 2: "ORDER_STATUS2_PROCESSING", 37 | 3: "ORDER_STATUS2_SHIPPED", 38 | 4: "ORDER_STATUS2_DELIVERED", 39 | } 40 | OrderStatus2_value = map[string]int32{ 41 | "ORDER_STATUS2_PENDING": 1, 42 | "ORDER_STATUS2_PROCESSING": 2, 43 | "ORDER_STATUS2_SHIPPED": 3, 44 | "ORDER_STATUS2_DELIVERED": 4, 45 | } 46 | ) 47 | 48 | func (x OrderStatus2) Enum() *OrderStatus2 { 49 | p := new(OrderStatus2) 50 | *p = x 51 | return p 52 | } 53 | 54 | func (x OrderStatus2) String() string { 55 | return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) 56 | } 57 | 58 | func (OrderStatus2) Descriptor() protoreflect.EnumDescriptor { 59 | return file_protos_order2_proto_enumTypes[0].Descriptor() 60 | } 61 | 62 | func (OrderStatus2) Type() protoreflect.EnumType { 63 | return &file_protos_order2_proto_enumTypes[0] 64 | } 65 | 66 | func (x OrderStatus2) Number() protoreflect.EnumNumber { 67 | return protoreflect.EnumNumber(x) 68 | } 69 | 70 | // Deprecated: Do not use. 71 | func (x *OrderStatus2) UnmarshalJSON(b []byte) error { 72 | num, err := protoimpl.X.UnmarshalJSONEnum(x.Descriptor(), b) 73 | if err != nil { 74 | return err 75 | } 76 | *x = OrderStatus2(num) 77 | return nil 78 | } 79 | 80 | // Deprecated: Use OrderStatus2.Descriptor instead. 81 | func (OrderStatus2) EnumDescriptor() ([]byte, []int) { 82 | return file_protos_order2_proto_rawDescGZIP(), []int{0} 83 | } 84 | 85 | type Order2 struct { 86 | state protoimpl.MessageState 87 | sizeCache protoimpl.SizeCache 88 | unknownFields protoimpl.UnknownFields 89 | 90 | OrderId *string `protobuf:"bytes,1,req,name=order_id,json=orderId" json:"order_id,omitempty"` 91 | Amount *float64 `protobuf:"fixed64,2,req,name=amount" json:"amount,omitempty"` 92 | Status *OrderStatus2 `protobuf:"varint,3,req,name=status,enum=models.OrderStatus2" json:"status,omitempty"` 93 | } 94 | 95 | func (x *Order2) Reset() { 96 | *x = Order2{} 97 | mi := &file_protos_order2_proto_msgTypes[0] 98 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 99 | ms.StoreMessageInfo(mi) 100 | } 101 | 102 | func (x *Order2) String() string { 103 | return protoimpl.X.MessageStringOf(x) 104 | } 105 | 106 | func (*Order2) ProtoMessage() {} 107 | 108 | func (x *Order2) ProtoReflect() protoreflect.Message { 109 | mi := &file_protos_order2_proto_msgTypes[0] 110 | if x != nil { 111 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 112 | if ms.LoadMessageInfo() == nil { 113 | ms.StoreMessageInfo(mi) 114 | } 115 | return ms 116 | } 117 | return mi.MessageOf(x) 118 | } 119 | 120 | // Deprecated: Use Order2.ProtoReflect.Descriptor instead. 121 | func (*Order2) Descriptor() ([]byte, []int) { 122 | return file_protos_order2_proto_rawDescGZIP(), []int{0} 123 | } 124 | 125 | func (x *Order2) GetOrderId() string { 126 | if x != nil && x.OrderId != nil { 127 | return *x.OrderId 128 | } 129 | return "" 130 | } 131 | 132 | func (x *Order2) GetAmount() float64 { 133 | if x != nil && x.Amount != nil { 134 | return *x.Amount 135 | } 136 | return 0 137 | } 138 | 139 | func (x *Order2) GetStatus() OrderStatus2 { 140 | if x != nil && x.Status != nil { 141 | return *x.Status 142 | } 143 | return OrderStatus2_ORDER_STATUS2_PENDING 144 | } 145 | 146 | var File_protos_order2_proto protoreflect.FileDescriptor 147 | 148 | var file_protos_order2_proto_rawDesc = []byte{ 149 | 0x0a, 0x13, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x73, 0x2f, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x32, 0x2e, 150 | 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x06, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x73, 0x22, 0x69, 0x0a, 151 | 0x06, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x32, 0x12, 0x19, 0x0a, 0x08, 0x6f, 0x72, 0x64, 0x65, 0x72, 152 | 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x02, 0x28, 0x09, 0x52, 0x07, 0x6f, 0x72, 0x64, 0x65, 0x72, 153 | 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x02, 154 | 0x28, 0x01, 0x52, 0x06, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x2c, 0x0a, 0x06, 0x73, 0x74, 155 | 0x61, 0x74, 0x75, 0x73, 0x18, 0x03, 0x20, 0x02, 0x28, 0x0e, 0x32, 0x14, 0x2e, 0x6d, 0x6f, 0x64, 156 | 0x65, 0x6c, 0x73, 0x2e, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x32, 157 | 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x2a, 0x7f, 0x0a, 0x0c, 0x4f, 0x72, 0x64, 0x65, 158 | 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x32, 0x12, 0x19, 0x0a, 0x15, 0x4f, 0x52, 0x44, 0x45, 159 | 0x52, 0x5f, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x32, 0x5f, 0x50, 0x45, 0x4e, 0x44, 0x49, 0x4e, 160 | 0x47, 0x10, 0x01, 0x12, 0x1c, 0x0a, 0x18, 0x4f, 0x52, 0x44, 0x45, 0x52, 0x5f, 0x53, 0x54, 0x41, 161 | 0x54, 0x55, 0x53, 0x32, 0x5f, 0x50, 0x52, 0x4f, 0x43, 0x45, 0x53, 0x53, 0x49, 0x4e, 0x47, 0x10, 162 | 0x02, 0x12, 0x19, 0x0a, 0x15, 0x4f, 0x52, 0x44, 0x45, 0x52, 0x5f, 0x53, 0x54, 0x41, 0x54, 0x55, 163 | 0x53, 0x32, 0x5f, 0x53, 0x48, 0x49, 0x50, 0x50, 0x45, 0x44, 0x10, 0x03, 0x12, 0x1b, 0x0a, 0x17, 164 | 0x4f, 0x52, 0x44, 0x45, 0x52, 0x5f, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x32, 0x5f, 0x44, 0x45, 165 | 0x4c, 0x49, 0x56, 0x45, 0x52, 0x45, 0x44, 0x10, 0x04, 0x42, 0x0a, 0x5a, 0x08, 0x2e, 0x3b, 0x6d, 166 | 0x6f, 0x64, 0x65, 0x6c, 0x73, 167 | } 168 | 169 | var ( 170 | file_protos_order2_proto_rawDescOnce sync.Once 171 | file_protos_order2_proto_rawDescData = file_protos_order2_proto_rawDesc 172 | ) 173 | 174 | func file_protos_order2_proto_rawDescGZIP() []byte { 175 | file_protos_order2_proto_rawDescOnce.Do(func() { 176 | file_protos_order2_proto_rawDescData = protoimpl.X.CompressGZIP(file_protos_order2_proto_rawDescData) 177 | }) 178 | return file_protos_order2_proto_rawDescData 179 | } 180 | 181 | var file_protos_order2_proto_enumTypes = make([]protoimpl.EnumInfo, 1) 182 | var file_protos_order2_proto_msgTypes = make([]protoimpl.MessageInfo, 1) 183 | var file_protos_order2_proto_goTypes = []any{ 184 | (OrderStatus2)(0), // 0: models.OrderStatus2 185 | (*Order2)(nil), // 1: models.Order2 186 | } 187 | var file_protos_order2_proto_depIdxs = []int32{ 188 | 0, // 0: models.Order2.status:type_name -> models.OrderStatus2 189 | 1, // [1:1] is the sub-list for method output_type 190 | 1, // [1:1] is the sub-list for method input_type 191 | 1, // [1:1] is the sub-list for extension type_name 192 | 1, // [1:1] is the sub-list for extension extendee 193 | 0, // [0:1] is the sub-list for field type_name 194 | } 195 | 196 | func init() { file_protos_order2_proto_init() } 197 | func file_protos_order2_proto_init() { 198 | if File_protos_order2_proto != nil { 199 | return 200 | } 201 | type x struct{} 202 | out := protoimpl.TypeBuilder{ 203 | File: protoimpl.DescBuilder{ 204 | GoPackagePath: reflect.TypeOf(x{}).PkgPath(), 205 | RawDescriptor: file_protos_order2_proto_rawDesc, 206 | NumEnums: 1, 207 | NumMessages: 1, 208 | NumExtensions: 0, 209 | NumServices: 0, 210 | }, 211 | GoTypes: file_protos_order2_proto_goTypes, 212 | DependencyIndexes: file_protos_order2_proto_depIdxs, 213 | EnumInfos: file_protos_order2_proto_enumTypes, 214 | MessageInfos: file_protos_order2_proto_msgTypes, 215 | }.Build() 216 | File_protos_order2_proto = out.File 217 | file_protos_order2_proto_rawDesc = nil 218 | file_protos_order2_proto_goTypes = nil 219 | file_protos_order2_proto_depIdxs = nil 220 | } 221 | -------------------------------------------------------------------------------- /4-enum/models/order3.pb.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoc-gen-go. DO NOT EDIT. 2 | // versions: 3 | // protoc-gen-go v1.35.2 4 | // protoc v4.25.1 5 | // source: protos/order3.proto 6 | 7 | package models 8 | 9 | import ( 10 | protoreflect "google.golang.org/protobuf/reflect/protoreflect" 11 | protoimpl "google.golang.org/protobuf/runtime/protoimpl" 12 | reflect "reflect" 13 | sync "sync" 14 | ) 15 | 16 | const ( 17 | // Verify that this generated code is sufficiently up-to-date. 18 | _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) 19 | // Verify that runtime/protoimpl is sufficiently up-to-date. 20 | _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) 21 | ) 22 | 23 | type OrderStatus3 int32 24 | 25 | const ( 26 | // remove ORDER_STATUS3 prefixes and it gives a compile-time error 27 | OrderStatus3_ORDER_STATUS3_UNSPECIFIDED OrderStatus3 = 0 // remove this line and it gives a compile-time error 28 | OrderStatus3_ORDER_STATUS3_PENDING OrderStatus3 = 1 29 | OrderStatus3_ORDER_STATUS3_PROCESSING OrderStatus3 = 2 30 | OrderStatus3_ORDER_STATUS3_SHIPPED OrderStatus3 = 3 31 | OrderStatus3_ORDER_STATUS3_DELIVERED OrderStatus3 = 4 32 | ) 33 | 34 | // Enum value maps for OrderStatus3. 35 | var ( 36 | OrderStatus3_name = map[int32]string{ 37 | 0: "ORDER_STATUS3_UNSPECIFIDED", 38 | 1: "ORDER_STATUS3_PENDING", 39 | 2: "ORDER_STATUS3_PROCESSING", 40 | 3: "ORDER_STATUS3_SHIPPED", 41 | 4: "ORDER_STATUS3_DELIVERED", 42 | } 43 | OrderStatus3_value = map[string]int32{ 44 | "ORDER_STATUS3_UNSPECIFIDED": 0, 45 | "ORDER_STATUS3_PENDING": 1, 46 | "ORDER_STATUS3_PROCESSING": 2, 47 | "ORDER_STATUS3_SHIPPED": 3, 48 | "ORDER_STATUS3_DELIVERED": 4, 49 | } 50 | ) 51 | 52 | func (x OrderStatus3) Enum() *OrderStatus3 { 53 | p := new(OrderStatus3) 54 | *p = x 55 | return p 56 | } 57 | 58 | func (x OrderStatus3) String() string { 59 | return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) 60 | } 61 | 62 | func (OrderStatus3) Descriptor() protoreflect.EnumDescriptor { 63 | return file_protos_order3_proto_enumTypes[0].Descriptor() 64 | } 65 | 66 | func (OrderStatus3) Type() protoreflect.EnumType { 67 | return &file_protos_order3_proto_enumTypes[0] 68 | } 69 | 70 | func (x OrderStatus3) Number() protoreflect.EnumNumber { 71 | return protoreflect.EnumNumber(x) 72 | } 73 | 74 | // Deprecated: Use OrderStatus3.Descriptor instead. 75 | func (OrderStatus3) EnumDescriptor() ([]byte, []int) { 76 | return file_protos_order3_proto_rawDescGZIP(), []int{0} 77 | } 78 | 79 | type Order3 struct { 80 | state protoimpl.MessageState 81 | sizeCache protoimpl.SizeCache 82 | unknownFields protoimpl.UnknownFields 83 | 84 | OrderId string `protobuf:"bytes,1,opt,name=order_id,json=orderId,proto3" json:"order_id,omitempty"` 85 | Amount float64 `protobuf:"fixed64,2,opt,name=amount,proto3" json:"amount,omitempty"` 86 | Status OrderStatus3 `protobuf:"varint,3,opt,name=status,proto3,enum=models.OrderStatus3" json:"status,omitempty"` 87 | } 88 | 89 | func (x *Order3) Reset() { 90 | *x = Order3{} 91 | mi := &file_protos_order3_proto_msgTypes[0] 92 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 93 | ms.StoreMessageInfo(mi) 94 | } 95 | 96 | func (x *Order3) String() string { 97 | return protoimpl.X.MessageStringOf(x) 98 | } 99 | 100 | func (*Order3) ProtoMessage() {} 101 | 102 | func (x *Order3) ProtoReflect() protoreflect.Message { 103 | mi := &file_protos_order3_proto_msgTypes[0] 104 | if x != nil { 105 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 106 | if ms.LoadMessageInfo() == nil { 107 | ms.StoreMessageInfo(mi) 108 | } 109 | return ms 110 | } 111 | return mi.MessageOf(x) 112 | } 113 | 114 | // Deprecated: Use Order3.ProtoReflect.Descriptor instead. 115 | func (*Order3) Descriptor() ([]byte, []int) { 116 | return file_protos_order3_proto_rawDescGZIP(), []int{0} 117 | } 118 | 119 | func (x *Order3) GetOrderId() string { 120 | if x != nil { 121 | return x.OrderId 122 | } 123 | return "" 124 | } 125 | 126 | func (x *Order3) GetAmount() float64 { 127 | if x != nil { 128 | return x.Amount 129 | } 130 | return 0 131 | } 132 | 133 | func (x *Order3) GetStatus() OrderStatus3 { 134 | if x != nil { 135 | return x.Status 136 | } 137 | return OrderStatus3_ORDER_STATUS3_UNSPECIFIDED 138 | } 139 | 140 | var File_protos_order3_proto protoreflect.FileDescriptor 141 | 142 | var file_protos_order3_proto_rawDesc = []byte{ 143 | 0x0a, 0x13, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x73, 0x2f, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x33, 0x2e, 144 | 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x06, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x73, 0x22, 0x69, 0x0a, 145 | 0x06, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x33, 0x12, 0x19, 0x0a, 0x08, 0x6f, 0x72, 0x64, 0x65, 0x72, 146 | 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6f, 0x72, 0x64, 0x65, 0x72, 147 | 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 148 | 0x28, 0x01, 0x52, 0x06, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x2c, 0x0a, 0x06, 0x73, 0x74, 149 | 0x61, 0x74, 0x75, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x14, 0x2e, 0x6d, 0x6f, 0x64, 150 | 0x65, 0x6c, 0x73, 0x2e, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x33, 151 | 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x2a, 0x9f, 0x01, 0x0a, 0x0c, 0x4f, 0x72, 0x64, 152 | 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x33, 0x12, 0x1e, 0x0a, 0x1a, 0x4f, 0x52, 0x44, 153 | 0x45, 0x52, 0x5f, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x33, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 154 | 0x43, 0x49, 0x46, 0x49, 0x44, 0x45, 0x44, 0x10, 0x00, 0x12, 0x19, 0x0a, 0x15, 0x4f, 0x52, 0x44, 155 | 0x45, 0x52, 0x5f, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x33, 0x5f, 0x50, 0x45, 0x4e, 0x44, 0x49, 156 | 0x4e, 0x47, 0x10, 0x01, 0x12, 0x1c, 0x0a, 0x18, 0x4f, 0x52, 0x44, 0x45, 0x52, 0x5f, 0x53, 0x54, 157 | 0x41, 0x54, 0x55, 0x53, 0x33, 0x5f, 0x50, 0x52, 0x4f, 0x43, 0x45, 0x53, 0x53, 0x49, 0x4e, 0x47, 158 | 0x10, 0x02, 0x12, 0x19, 0x0a, 0x15, 0x4f, 0x52, 0x44, 0x45, 0x52, 0x5f, 0x53, 0x54, 0x41, 0x54, 159 | 0x55, 0x53, 0x33, 0x5f, 0x53, 0x48, 0x49, 0x50, 0x50, 0x45, 0x44, 0x10, 0x03, 0x12, 0x1b, 0x0a, 160 | 0x17, 0x4f, 0x52, 0x44, 0x45, 0x52, 0x5f, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x33, 0x5f, 0x44, 161 | 0x45, 0x4c, 0x49, 0x56, 0x45, 0x52, 0x45, 0x44, 0x10, 0x04, 0x42, 0x0a, 0x5a, 0x08, 0x2e, 0x3b, 162 | 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, 163 | } 164 | 165 | var ( 166 | file_protos_order3_proto_rawDescOnce sync.Once 167 | file_protos_order3_proto_rawDescData = file_protos_order3_proto_rawDesc 168 | ) 169 | 170 | func file_protos_order3_proto_rawDescGZIP() []byte { 171 | file_protos_order3_proto_rawDescOnce.Do(func() { 172 | file_protos_order3_proto_rawDescData = protoimpl.X.CompressGZIP(file_protos_order3_proto_rawDescData) 173 | }) 174 | return file_protos_order3_proto_rawDescData 175 | } 176 | 177 | var file_protos_order3_proto_enumTypes = make([]protoimpl.EnumInfo, 1) 178 | var file_protos_order3_proto_msgTypes = make([]protoimpl.MessageInfo, 1) 179 | var file_protos_order3_proto_goTypes = []any{ 180 | (OrderStatus3)(0), // 0: models.OrderStatus3 181 | (*Order3)(nil), // 1: models.Order3 182 | } 183 | var file_protos_order3_proto_depIdxs = []int32{ 184 | 0, // 0: models.Order3.status:type_name -> models.OrderStatus3 185 | 1, // [1:1] is the sub-list for method output_type 186 | 1, // [1:1] is the sub-list for method input_type 187 | 1, // [1:1] is the sub-list for extension type_name 188 | 1, // [1:1] is the sub-list for extension extendee 189 | 0, // [0:1] is the sub-list for field type_name 190 | } 191 | 192 | func init() { file_protos_order3_proto_init() } 193 | func file_protos_order3_proto_init() { 194 | if File_protos_order3_proto != nil { 195 | return 196 | } 197 | type x struct{} 198 | out := protoimpl.TypeBuilder{ 199 | File: protoimpl.DescBuilder{ 200 | GoPackagePath: reflect.TypeOf(x{}).PkgPath(), 201 | RawDescriptor: file_protos_order3_proto_rawDesc, 202 | NumEnums: 1, 203 | NumMessages: 1, 204 | NumExtensions: 0, 205 | NumServices: 0, 206 | }, 207 | GoTypes: file_protos_order3_proto_goTypes, 208 | DependencyIndexes: file_protos_order3_proto_depIdxs, 209 | EnumInfos: file_protos_order3_proto_enumTypes, 210 | MessageInfos: file_protos_order3_proto_msgTypes, 211 | }.Build() 212 | File_protos_order3_proto = out.File 213 | file_protos_order3_proto_rawDesc = nil 214 | file_protos_order3_proto_goTypes = nil 215 | file_protos_order3_proto_depIdxs = nil 216 | } 217 | --------------------------------------------------------------------------------