-
-
Save ydnar/fbb49f92412ecd6bb895b36e90c9a707 to your computer and use it in GitHub Desktop.
protoc-gen-go-patch example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
syntax = "proto3"; | |
package example; | |
import "google/protobuf/duration.proto"; | |
import "google/protobuf/timestamp.proto"; | |
import "patch/go.proto"; | |
option go_package = "github.com/example/example;example"; | |
// Person represents an individual person’s name. | |
enum Person { | |
option (go_enum_name) = 'Person'; | |
UNKNOWN = 0 [(go_value_name) = 'PersonUnknown']; | |
ALICE = 1; | |
BOB = 2; | |
CHARLIE = 3; | |
} | |
// Example represents an example Protobuf. | |
message Example { | |
option (go_message_name) = 'Experiment'; | |
string id = 1 [(go_name) = 'ID', (go_tags) = 'foo:"bar,omitempty"']; | |
google.protobuf.Timestamp run_at = 2; | |
google.protobuf.Duration interval = 3; | |
string request_url = 4 [(go_name) = 'RequestURL']; | |
bool xml_http_request = 5 [(go_name) = 'XMLHTTPRequest']; | |
bool cors_request = 6 [(go_name) = 'CORSRequest']; | |
bool imap_request = 7 [(go_name) = 'IMAPRequest']; | |
Person person = 8; | |
} | |
message Foo { | |
option (go_message_name) = 'Bar'; | |
string id = 1 [(go_name) = 'ID']; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
syntax = "proto2"; | |
// There is explcitly no package definition. | |
// This allows users of this extension to specify an unqualified 'go_name' option on message fields. | |
import "google/protobuf/descriptor.proto"; | |
option go_package = "github.com/org/repo/patch;patch"; | |
extend google.protobuf.MessageOptions { | |
optional string go_message_name = 6001 [(go_name) = 'ExtMessageName']; | |
} | |
extend google.protobuf.FieldOptions { | |
optional string go_name = 6001 [(go_name) = 'ExtName']; | |
// optional string go_type = 6002; | |
optional string go_tags = 6003 [(go_name) = 'ExtTags']; | |
} | |
extend google.protobuf.EnumOptions { | |
optional string go_enum_name = 6001 [(go_name) = 'ExtEnumName']; | |
} | |
extend google.protobuf.EnumValueOptions { | |
optional string go_value_name = 6001 [(go_name) = 'ExtValueName']; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment