From ad8fe63ecbae240ecc1fa1e2396d66a1357a0ca2 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Wed, 8 Oct 2025 10:36:25 -0500 Subject: maybe helpful --- Makefile | 5 ++++- filetype.proto | 25 +++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 filetype.proto diff --git a/Makefile b/Makefile index ab46d8f..62059f3 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,7 @@ -all: generate vet +all: goimports vet + +proto: + autogenpb --renumber --proto filetype.proto generate: clean go mod init diff --git a/filetype.proto b/filetype.proto new file mode 100644 index 0000000..8367890 --- /dev/null +++ b/filetype.proto @@ -0,0 +1,25 @@ +syntax = "proto3"; + +package main; + +message Filetype { // `autogenpb:var:w io.Writer` + bool nothing = 1; // generate autosave functions (in marshal.go ?) +} + +// 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 Filetypes { // `autogenpb:marshal` + string uuid = 1; // `autogenpb:uuid:c1239110-ad4f-41f3-b0f5-189034f0a3a7` + string version = 2; // `autogenpb:version:v0.0.1` + repeated Filetype Filetypes = 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; // + string version = 2; // +} -- cgit v1.2.3 From c0ca88c692d7bc415980728b301921110c085256 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Wed, 8 Oct 2025 10:48:55 -0500 Subject: identify .pb files --- Makefile | 5 ++++- filetype.proto | 2 +- generate.go | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 62059f3..bc6bec7 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,9 @@ all: goimports vet -proto: +# run this the first time here +proto:clean autogenpb goimports vet + +autogenpb: autogenpb --renumber --proto filetype.proto generate: clean diff --git a/filetype.proto b/filetype.proto index 8367890..7ec6006 100644 --- a/filetype.proto +++ b/filetype.proto @@ -1,6 +1,6 @@ syntax = "proto3"; -package main; +package filepb; message Filetype { // `autogenpb:var:w io.Writer` bool nothing = 1; // generate autosave functions (in marshal.go ?) diff --git a/generate.go b/generate.go index 91503d8..575bec8 100644 --- a/generate.go +++ b/generate.go @@ -1,4 +1,4 @@ -package golib +package filepb // NOTE: it would be helpful if go.mod doesn't exist, that go generate // would automatically run go mod init and go mod tidy -- cgit v1.2.3