Skip to content

Commit

Permalink
Allow google.protobuf.Timestamp field to be named time (uber#336)
Browse files Browse the repository at this point in the history
  • Loading branch information
bufdev authored Feb 12, 2019
1 parent ad3cc20 commit b9ce670
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions internal/cmd/testdata/lint/wktsuffix/foo/foo.proto
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,6 @@ message Bar {
google.protobuf.Timestamp three = 3;
google.protobuf.Duration four = 4;
}
// Make sure this is allowed.
google.protobuf.Timestamp time = 5;
}
4 changes: 2 additions & 2 deletions internal/lint/check_wkt_timestamp_suffix.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func (v wktTimestampSuffixVisitor) VisitOneofField(field *proto.OneOfField) {
}

func (v wktTimestampSuffixVisitor) visitField(field *proto.Field) {
if field.Type == "google.protobuf.Timestamp" && !strings.HasSuffix(field.Name, "_time") {
v.AddFailuref(field.Position, `Field %q of type "google.protobuf.Timestamp" must end in "_time".`, field.Name)
if field.Type == "google.protobuf.Timestamp" && !(field.Name == "time" || strings.HasSuffix(field.Name, "_time")) {
v.AddFailuref(field.Position, `Field %q of type "google.protobuf.Timestamp" must be "time" or end in "_time".`, field.Name)
}
}

0 comments on commit b9ce670

Please sign in to comment.