Skip to content

Commit

Permalink
Add RepeatedString
Browse files Browse the repository at this point in the history
  • Loading branch information
PumpkinSeed committed Oct 6, 2022
1 parent bd5a4a0 commit 09a3a4b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ These are actually environment variables.
Supported overwrite:

- `TimeTime` -> `time.Time`
- `RepeatedString` -> `[]string`

#### Example

Expand Down
4 changes: 4 additions & 0 deletions cmd/protoc-gen-go/internal_gengo/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -927,6 +927,10 @@ func goTypeOverride(goType string) string {
case "TimeTime":
return "time.Time"
}

if strings.Contains(goType, "RepeatedString") {
return strings.ReplaceAll(goType, "RepeatedString", "[]string")
}
}
return goType
}
4 changes: 3 additions & 1 deletion cmd/protoc-gen-go/internal_gengo/test_data/test.proto
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ package proto;

message Test {
TimeTime created_at = 1;
map<uint64, string> map_field = 2;
map<uint64, RepeatedString> map_field = 2;
string test = 3;
String other = 43;
}

message TimeTime {}

message RepeatedString {}

message String {
string string = 2;
}

0 comments on commit 09a3a4b

Please sign in to comment.