diff options
| author | Jeff Carr <[email protected]> | 2025-01-10 07:40:24 -0600 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2025-01-10 07:40:24 -0600 |
| commit | e07c6a35fd5d2ca1b3a6c09d9781d21f676f52f2 (patch) | |
| tree | ce7a4fd38fff09571739bedd5d6dd00d99cff4b7 /example/file.proto | |
| parent | d9e5edb3a8486bc884841137095dd910e42b3a98 (diff) | |
detect that autogenpb has already been run and exit
Diffstat (limited to 'example/file.proto')
| -rw-r--r-- | example/file.proto | 93 |
1 files changed, 32 insertions, 61 deletions
diff --git a/example/file.proto b/example/file.proto index d65ccd0..18b096a 100644 --- a/example/file.proto +++ b/example/file.proto @@ -1,5 +1,9 @@ syntax = "proto3"; +// Look at "example/fruit.proto" not this file + +// this file is actually used by autogenpb + // here are some docs, but probably it's just easier to run // autogenpb on this file and see what gets autogenerated // in this directory. All autogenerated files are named *.pb.go @@ -15,76 +19,43 @@ syntax = "proto3"; package main; -message Apple { // `autogenpb:marshal` - string name = 1; // `autogenpb:unique` // generates SortByxxx() and AppendUnique() functions - string genus = 2; // `autogenpb:unique` // generates same thing here but SortByGenus() -} - -message Apples { // `autogenpb:marshal` `autogenpb:mutex` - string uuid = 1; // `autogenpb:default:b2a2de35-07b6-443b-8188-709e27bee8a7` - string version = 2; // `autogenpb:default:2` - repeated Apple apples = 3; // `autogenpb:sort` `autogenpb:unique` - repeated Pear pears = 4; // `autogenpb:sort` `autogenpb:unique` - repeated Pear more = 5; // `autogenpb:sort` `autogenpb:unique` // not supported. 'More' can only be the string 'Pears' - repeated string color = 6; // `autogenpb:sort` `autogenpb:unique` -} - -message Pear { - string name = 1; // - string favorite = 2; // `autogenpb:sort` -} - -// above is an example - // // below are the actual structs autogen uses // autogen parses the .proto file and then store the information // it needs in these protobuf files, then it processes the // protobuf files to write out *.sort.pb.go and *.marshal.pb.go files // -message MsgName { - // If you have: - // - // "Shelf" for msgname - // "Books" for name - // - // Then in the proto file, that would mean it would look like: - // - // message Shelf { - // and then - // repeated string Books = 42; - // - // autogenpb will then generate sort functions for each 'name' - // things like: - // - // for _, b := range all.Book { - // - // and sort functions like: - // - // func (a ShelfBook) Less(i, j int) bool { return a[i].Book < a[j].Book } - // - - string name = 1; // the name of the message aka struct. for this example: "Shelf" - bool marshal = 2; // if "Shelf" should have Marshal & Unmarshal functions - bool mutex = 3; // an experiment to insert a mutex into the protoc generated msg struct (bad idea?) - repeated string sort = 4; // "Book", "Picture", etc - repeated string aq = 5; // if the fields should have AppendUnique() functions - repeated string uniq = 6; // the non-repeating fields that should be unique +message MsgVar { + string varName = 1; // the variable name + string varType = 2; // the variable type + bool isRepeated = 3; // does the variable repeate } -message Unique { - string name = 1; // the variable name of the repeatable struct that must be unique - string msgName = 2; // the struct that is repeated - repeated string keys = 3; // the variables in that structure to check are unique +message MsgName { + string name = 1; // the name of the message aka struct. for this example: "Shelf" + string lockname = 2; // name of the lockfile. ends in Mu + bool doMarshal = 3; // if msg struct should have Marshal & Unmarshal functions + bool doMutex = 4; // true if a mutex is needed for the message struct + bool doProtocMutex = 5; // an experiment to insert a mutex into the protoc generated msg struct (bad idea?) + bool mutexFound = 6; // true if the mutex was added to the protoc pb.go file + repeated string sort = 7; // keys to sort on + repeated string unique = 8; // if the fields should have AppendUnique() functions + repeated MsgVar vars = 9; // store all the vars in the message } -message File { // `autogenpb:nomarshal` - string name = 1; // for this one: autogen.proto - string uuid = 2; // the uuid to use in a func NewMsgName() - int64 version = 3; // the version to use in a func NewMsgName() +message File { + string Package = 1; // whatever the package name is at the top of the .go file + string filename = 2; // yellow.proto + string pbfilename = 3; // yellow.pb.go + string filebase = 4; // yellow + string uuid = 5; // the uuid to use in a func NewMsgName() + string version = 6; // the version to use in a func NewMsgName() + MsgName bases = 7; // the message in "plural" form + MsgName base = 8; // the primary repeated message for the master struct - // in this proto file, this would have "Apple", "Apples", ... "File", etc... - repeated MsgName msgNames = 4; // `autogenpb:unique` // in this file + // every struct in this proto file, this file has: "Apple", "Apples", ... "File", etc... + repeated MsgName msgNames = 9; + repeated MsgName sortNames = 10; // variables that are repeated can have the standard functions generated (Sort(), etc) } // I know, I know, the whole point of using protobuf @@ -94,8 +65,8 @@ message File { // `autogenpb:nomarshal` // also, this could be used to modify /usr/bin/file /usr/share/magic to identify the files // maybe this is already been done and is pointless, but it seems like a good idea message Files { // `autogenpb:marshal` - string uuid = 1; // `autogenpb:uuid:fakeuuid` - string version = 2; // `autogenpb:id:42` + string uuid = 1; // `autogenpb:uuid:6c9ae4dd-648d-4b51-9738-bd59fb8fafd5` + string version = 2; // `autogenpb:version:v0.0.38` repeated File Files = 3; // an array of each .proto file in the working directory } |
