Skip to content

Commit 3caab00

Browse files
committed
wkt any. removed 'any' from generating a standard NewPopulated method and rather use a jsonpb friendly version. when you marshal with jsonpb it expects a registered proto message since it has to unmarshal it in order to format it in the 'any' json format. The new populated method just uses a random Duration wkt which is already in the same package.
1 parent 4c00d2f commit 3caab00

File tree

12 files changed

+1466
-1243
lines changed

12 files changed

+1466
-1243
lines changed

protoc-gen-gogotypes/main.go

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,21 +53,17 @@ func main() {
5353

5454
vanity.ForEachFile(files, vanity.TurnOnMessageNameAll)
5555

56-
for _, file := range files {
57-
if strings.HasSuffix(file.GetName(), "struct.proto") {
58-
// TODO struct can also get a compare method when
59-
// https://github.com/gogo/protobuf/issues/221 is fixed
60-
//continue
61-
}
62-
vanity.TurnOnCompareAll(file)
63-
}
56+
vanity.ForEachFile(files, vanity.TurnOnCompareAll)
6457

6558
for _, file := range files {
6659
if strings.HasSuffix(file.GetName(), "timestamp.proto") ||
6760
strings.HasSuffix(file.GetName(), "duration.proto") {
6861
continue
6962
}
7063
vanity.TurnOnStringerAll(file)
64+
if strings.HasSuffix(file.GetName(), "any.proto") {
65+
continue
66+
}
7167
vanity.TurnOnPopulateAll(file)
7268
}
7369

test/types/combos/both/types.pb.go

Lines changed: 467 additions & 395 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/types/combos/both/types.proto

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ package types;
3232

3333
import "github.com/gogo/protobuf/gogoproto/gogo.proto";
3434

35-
//import "google/protobuf/any.proto";
35+
import "google/protobuf/any.proto";
3636
import "google/protobuf/duration.proto";
3737
import "google/protobuf/struct.proto";
3838
import "google/protobuf/timestamp.proto";
@@ -62,10 +62,8 @@ message KnownTypes {
6262
google.protobuf.BoolValue bool = 9;
6363
google.protobuf.StringValue str = 10;
6464
google.protobuf.BytesValue bytes = 11;
65-
66-
// TODO uncomment this once https://github.com/gogo/protobuf/issues/197 is fixed
6765
google.protobuf.Struct st = 12;
68-
// google.protobuf.Any an = 14;
66+
google.protobuf.Any an = 14;
6967
}
7068

7169
message ProtoTypes {

test/types/combos/marshaler/types.pb.go

Lines changed: 433 additions & 396 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/types/combos/marshaler/types.proto

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ package types;
3232

3333
import "github.com/gogo/protobuf/gogoproto/gogo.proto";
3434

35-
//import "google/protobuf/any.proto";
35+
import "google/protobuf/any.proto";
3636
import "google/protobuf/duration.proto";
3737
import "google/protobuf/struct.proto";
3838
import "google/protobuf/timestamp.proto";
@@ -62,10 +62,8 @@ message KnownTypes {
6262
google.protobuf.BoolValue bool = 9;
6363
google.protobuf.StringValue str = 10;
6464
google.protobuf.BytesValue bytes = 11;
65-
66-
// TODO uncomment this once https://github.com/gogo/protobuf/issues/197 is fixed
6765
google.protobuf.Struct st = 12;
68-
// google.protobuf.Any an = 14;
66+
google.protobuf.Any an = 14;
6967
}
7068

7169
message ProtoTypes {

test/types/combos/neither/types.pb.go

Lines changed: 188 additions & 164 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/types/combos/neither/types.proto

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ package types;
3232

3333
import "github.com/gogo/protobuf/gogoproto/gogo.proto";
3434

35-
//import "google/protobuf/any.proto";
35+
import "google/protobuf/any.proto";
3636
import "google/protobuf/duration.proto";
3737
import "google/protobuf/struct.proto";
3838
import "google/protobuf/timestamp.proto";
@@ -62,10 +62,8 @@ message KnownTypes {
6262
google.protobuf.BoolValue bool = 9;
6363
google.protobuf.StringValue str = 10;
6464
google.protobuf.BytesValue bytes = 11;
65-
66-
// TODO uncomment this once https://github.com/gogo/protobuf/issues/197 is fixed
6765
google.protobuf.Struct st = 12;
68-
// google.protobuf.Any an = 14;
66+
google.protobuf.Any an = 14;
6967
}
7068

7169
message ProtoTypes {

test/types/combos/unmarshaler/types.pb.go

Lines changed: 225 additions & 164 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/types/combos/unmarshaler/types.proto

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ package types;
3232

3333
import "github.com/gogo/protobuf/gogoproto/gogo.proto";
3434

35-
//import "google/protobuf/any.proto";
35+
import "google/protobuf/any.proto";
3636
import "google/protobuf/duration.proto";
3737
import "google/protobuf/struct.proto";
3838
import "google/protobuf/timestamp.proto";
@@ -62,10 +62,8 @@ message KnownTypes {
6262
google.protobuf.BoolValue bool = 9;
6363
google.protobuf.StringValue str = 10;
6464
google.protobuf.BytesValue bytes = 11;
65-
66-
// TODO uncomment this once https://github.com/gogo/protobuf/issues/197 is fixed
6765
google.protobuf.Struct st = 12;
68-
// google.protobuf.Any an = 14;
66+
google.protobuf.Any an = 14;
6967
}
7068

7169
message ProtoTypes {

test/types/types.proto

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ package types;
3232

3333
import "github.com/gogo/protobuf/gogoproto/gogo.proto";
3434

35-
//import "google/protobuf/any.proto";
35+
import "google/protobuf/any.proto";
3636
import "google/protobuf/duration.proto";
3737
import "google/protobuf/struct.proto";
3838
import "google/protobuf/timestamp.proto";
@@ -62,10 +62,8 @@ message KnownTypes {
6262
google.protobuf.BoolValue bool = 9;
6363
google.protobuf.StringValue str = 10;
6464
google.protobuf.BytesValue bytes = 11;
65-
66-
// TODO uncomment this once https://github.com/gogo/protobuf/issues/197 is fixed
6765
google.protobuf.Struct st = 12;
68-
// google.protobuf.Any an = 14;
66+
google.protobuf.Any an = 14;
6967
}
7068

7169
message ProtoTypes {

0 commit comments

Comments
 (0)