cmd/protoc-gen-go: refactor logic to be more compartmentalized
This CL makes no feature changes except to move code around.
The only change to the actual generated code is the placement of
the default constants and variables. They move because the new logic
generates all methods together, while previously the constants
were interspersed in-between.
Change-Id: I45932d5aeec5ba45180fb255ea17898beb6c3bd2
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/186878
Reviewed-by: Herbie Ong <herbie@google.com>
diff --git a/internal/testprotos/test/test.pb.go b/internal/testprotos/test/test.pb.go
index da84d37..a9fddef 100644
--- a/internal/testprotos/test/test.pb.go
+++ b/internal/testprotos/test/test.pb.go
@@ -333,6 +333,26 @@
unknownFields protoimpl.UnknownFields
}
+const Default_TestAllTypes_DefaultInt32 int32 = 81
+const Default_TestAllTypes_DefaultInt64 int64 = 82
+const Default_TestAllTypes_DefaultUint32 uint32 = 83
+const Default_TestAllTypes_DefaultUint64 uint64 = 84
+const Default_TestAllTypes_DefaultSint32 int32 = -85
+const Default_TestAllTypes_DefaultSint64 int64 = 86
+const Default_TestAllTypes_DefaultFixed32 uint32 = 87
+const Default_TestAllTypes_DefaultFixed64 uint64 = 88
+const Default_TestAllTypes_DefaultSfixed32 int32 = 89
+const Default_TestAllTypes_DefaultSfixed64 int64 = -90
+const Default_TestAllTypes_DefaultFloat float32 = 91.5
+const Default_TestAllTypes_DefaultDouble float64 = 92000
+const Default_TestAllTypes_DefaultBool bool = true
+const Default_TestAllTypes_DefaultString string = "hello"
+
+var Default_TestAllTypes_DefaultBytes []byte = []byte("world")
+
+const Default_TestAllTypes_DefaultNestedEnum TestAllTypes_NestedEnum = TestAllTypes_BAR
+const Default_TestAllTypes_DefaultForeignEnum ForeignEnum = ForeignEnum_FOREIGN_BAR
+
func (x *TestAllTypes) Reset() {
*x = TestAllTypes{}
}
@@ -360,26 +380,6 @@
return file_test_test_proto_rawDescGZIP(), []int{0}
}
-const Default_TestAllTypes_DefaultInt32 int32 = 81
-const Default_TestAllTypes_DefaultInt64 int64 = 82
-const Default_TestAllTypes_DefaultUint32 uint32 = 83
-const Default_TestAllTypes_DefaultUint64 uint64 = 84
-const Default_TestAllTypes_DefaultSint32 int32 = -85
-const Default_TestAllTypes_DefaultSint64 int64 = 86
-const Default_TestAllTypes_DefaultFixed32 uint32 = 87
-const Default_TestAllTypes_DefaultFixed64 uint64 = 88
-const Default_TestAllTypes_DefaultSfixed32 int32 = 89
-const Default_TestAllTypes_DefaultSfixed64 int64 = -90
-const Default_TestAllTypes_DefaultFloat float32 = 91.5
-const Default_TestAllTypes_DefaultDouble float64 = 92000
-const Default_TestAllTypes_DefaultBool bool = true
-const Default_TestAllTypes_DefaultString string = "hello"
-
-var Default_TestAllTypes_DefaultBytes []byte = []byte("world")
-
-const Default_TestAllTypes_DefaultNestedEnum TestAllTypes_NestedEnum = TestAllTypes_BAR
-const Default_TestAllTypes_DefaultForeignEnum ForeignEnum = ForeignEnum_FOREIGN_BAR
-
func (x *TestAllTypes) GetOptionalInt32() int32 {
if x != nil && x.OptionalInt32 != nil {
return *x.OptionalInt32
@@ -1585,6 +1585,7 @@
}
return protoimpl.X.WeakNil("goproto.proto.test.weak.WeakImportMessage1")
}
+
func (x *TestWeak) GetWeakMessage2() protoiface.MessageV1 {
if x != nil {
v := x.XXX_weak[2]
@@ -1595,6 +1596,7 @@
}
return protoimpl.X.WeakNil("goproto.proto.test.weak.WeakImportMessage2")
}
+
func (x *TestWeak) SetWeakMessage1(v protoiface.MessageV1) {
if x.XXX_weak == nil {
x.XXX_weak = make(protoimpl.WeakFields)