cmd/protoc-gen-go: generate oneof types seperately

Seperate out the generation of the oneof wrapper types from the
code block that is about getter methods.

Change-Id: Ief44ef953d0b5ad8c998a8542c830ca70468a3bf
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/171029
Reviewed-by: Damien Neil <dneil@google.com>
diff --git a/encoding/testprotos/pb2/test.pb.go b/encoding/testprotos/pb2/test.pb.go
index e5bfe82..a9d1131 100644
--- a/encoding/testprotos/pb2/test.pb.go
+++ b/encoding/testprotos/pb2/test.pb.go
@@ -759,16 +759,6 @@
 	return nil
 }
 
-type isIndirectRequired_Union interface {
-	isIndirectRequired_Union()
-}
-
-type IndirectRequired_OneofNested struct {
-	OneofNested *NestedWithRequired `protobuf:"bytes,4,opt,name=oneof_nested,json=oneofNested,oneof"`
-}
-
-func (*IndirectRequired_OneofNested) isIndirectRequired_Union() {}
-
 func (m *IndirectRequired) GetUnion() isIndirectRequired_Union {
 	if m != nil {
 		return m.Union
@@ -790,6 +780,16 @@
 	}
 }
 
+type isIndirectRequired_Union interface {
+	isIndirectRequired_Union()
+}
+
+type IndirectRequired_OneofNested struct {
+	OneofNested *NestedWithRequired `protobuf:"bytes,4,opt,name=oneof_nested,json=oneofNested,oneof"`
+}
+
+func (*IndirectRequired_OneofNested) isIndirectRequired_Union() {}
+
 type Extensions struct {
 	OptString              *string                     `protobuf:"bytes,1,opt,name=opt_string,json=optString" json:"opt_string,omitempty"`
 	OptBool                *bool                       `protobuf:"varint,101,opt,name=opt_bool,json=optBool" json:"opt_bool,omitempty"`
diff --git a/encoding/testprotos/pb3/test.pb.go b/encoding/testprotos/pb3/test.pb.go
index 383db64..3091b4a 100644
--- a/encoding/testprotos/pb3/test.pb.go
+++ b/encoding/testprotos/pb3/test.pb.go
@@ -412,28 +412,6 @@
 	return xxx_File_pb3_test_proto_rawDescGZIP(), []int{4}
 }
 
-type isOneofs_Union interface {
-	isOneofs_Union()
-}
-
-type Oneofs_OneofEnum struct {
-	OneofEnum Enum `protobuf:"varint,1,opt,name=oneof_enum,json=oneofEnum,proto3,enum=pb3.Enum,oneof"`
-}
-
-type Oneofs_OneofString struct {
-	OneofString string `protobuf:"bytes,2,opt,name=oneof_string,json=oneofString,proto3,oneof"`
-}
-
-type Oneofs_OneofNested struct {
-	OneofNested *Nested `protobuf:"bytes,3,opt,name=oneof_nested,json=oneofNested,proto3,oneof"`
-}
-
-func (*Oneofs_OneofEnum) isOneofs_Union() {}
-
-func (*Oneofs_OneofString) isOneofs_Union() {}
-
-func (*Oneofs_OneofNested) isOneofs_Union() {}
-
 func (m *Oneofs) GetUnion() isOneofs_Union {
 	if m != nil {
 		return m.Union
@@ -471,6 +449,28 @@
 	}
 }
 
+type isOneofs_Union interface {
+	isOneofs_Union()
+}
+
+type Oneofs_OneofEnum struct {
+	OneofEnum Enum `protobuf:"varint,1,opt,name=oneof_enum,json=oneofEnum,proto3,enum=pb3.Enum,oneof"`
+}
+
+type Oneofs_OneofString struct {
+	OneofString string `protobuf:"bytes,2,opt,name=oneof_string,json=oneofString,proto3,oneof"`
+}
+
+type Oneofs_OneofNested struct {
+	OneofNested *Nested `protobuf:"bytes,3,opt,name=oneof_nested,json=oneofNested,proto3,oneof"`
+}
+
+func (*Oneofs_OneofEnum) isOneofs_Union() {}
+
+func (*Oneofs_OneofString) isOneofs_Union() {}
+
+func (*Oneofs_OneofNested) isOneofs_Union() {}
+
 // Message contains map fields.
 type Maps struct {
 	Int32ToStr           map[int32]string   `protobuf:"bytes,1,rep,name=int32_to_str,json=int32ToStr,proto3" json:"int32_to_str,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`