From b111cdd1f96a41c80abf368955aa4f50fe38782f Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Thu, 9 Jan 2025 21:24:47 -0600 Subject: can't leave extra .proto files in your repo --- auto.proto | 70 ------------------------------------------------------ example/auto.proto | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+), 70 deletions(-) delete mode 100644 auto.proto create mode 100644 example/auto.proto diff --git a/auto.proto b/auto.proto deleted file mode 100644 index 87e6836..0000000 --- a/auto.proto +++ /dev/null @@ -1,70 +0,0 @@ -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 - -// the 'uuid' standard at the end is an experiment -// establish a way to identify arbitrary .pb files - -// You can generate Marshal & Unmarshal for any struct (message) you want -// You can generate SortBy and Append functions ONLY FOR 'repeated ' -// Also, those structs must be defined in the same file -// Additionally, you must use `autogenpb:mutex` on the parent struct. -// The autogenerated code requires a RW mutex and autogenpb will insert it into the struct - -package main; - -// -// 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 { - 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 -} - -message File { // `autogenpb:nomarshal` - 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 - - // every struct in this proto file, this file has: "Apple", "Apples", ... "File", etc... - repeated MsgName msgNames = 9; // `autogenpb:unique` // in this file -} - -// I know, I know, the whole point of using protobuf -// is so you don't need a uuid or versions because it's -// inherently forward compatable. nonetheless, a simple stubbed out -// trivial and empty protobuf message can marshal and identify all the files -// 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: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 -} - -// this generic message is used by autogen to identify and -// then dump the uuid and version from any arbitrary .pb file -message Identify { // `autogenpb:marshal` - string uuid = 1; // - int64 version = 2; // -} diff --git a/example/auto.proto b/example/auto.proto new file mode 100644 index 0000000..87e6836 --- /dev/null +++ b/example/auto.proto @@ -0,0 +1,70 @@ +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 + +// the 'uuid' standard at the end is an experiment +// establish a way to identify arbitrary .pb files + +// You can generate Marshal & Unmarshal for any struct (message) you want +// You can generate SortBy and Append functions ONLY FOR 'repeated ' +// Also, those structs must be defined in the same file +// Additionally, you must use `autogenpb:mutex` on the parent struct. +// The autogenerated code requires a RW mutex and autogenpb will insert it into the struct + +package main; + +// +// 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 { + 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 +} + +message File { // `autogenpb:nomarshal` + 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 + + // every struct in this proto file, this file has: "Apple", "Apples", ... "File", etc... + repeated MsgName msgNames = 9; // `autogenpb:unique` // in this file +} + +// I know, I know, the whole point of using protobuf +// is so you don't need a uuid or versions because it's +// inherently forward compatable. nonetheless, a simple stubbed out +// trivial and empty protobuf message can marshal and identify all the files +// 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: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 +} + +// this generic message is used by autogen to identify and +// then dump the uuid and version from any arbitrary .pb file +message Identify { // `autogenpb:marshal` + string uuid = 1; // + int64 version = 2; // +} -- cgit v1.2.3