From ca7fb100efeda7b58a955acea3f342898cf29d61 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Thu, 9 Oct 2025 01:04:09 -0500 Subject: common protobuf makefile --- Makefile | 26 +++++++++++++++----------- filetype.proto | 1 + generate.go | 3 +++ 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/Makefile b/Makefile index bc6bec7..aa6482e 100644 --- a/Makefile +++ b/Makefile @@ -1,10 +1,16 @@ -all: goimports vet +all: filetype.pb.go goimports vet + @echo This GO code passes the compile checks -# run this the first time here -proto:clean autogenpb goimports vet - -autogenpb: +# fixes your numbers if you move things around +# THIS TOTALLY BREAKS THE POINT OF PROTOBUF +# To work around that breaking, you must change the version +# also, all the wrapping code must support this. which it doesn't +proto-renumber: clean autogenpb --renumber --proto filetype.proto + make goimports vet + +filetype.pb.go: filetype.proto + make generate generate: clean go mod init @@ -14,15 +20,13 @@ generate: clean go-generate: rm -f *.pb.go *.patch -vet: - @GO111MODULE=off go vet - @echo this go library package builds okay - -# autofixes your import headers in your golang files goimports: goimports -w *.go +vet: + @GO111MODULE=off go vet + clean: rm -f *.pb.go *.patch -rm -f go.* - -go-mod-clean purge + go-mod-clean purge diff --git a/filetype.proto b/filetype.proto index b18e069..3f333aa 100644 --- a/filetype.proto +++ b/filetype.proto @@ -4,6 +4,7 @@ package filepb; // 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; // diff --git a/generate.go b/generate.go index 575bec8..72b6759 100644 --- a/generate.go +++ b/generate.go @@ -6,4 +6,7 @@ package filepb // then this process could be fully automated // //go:generate make go-generate +//go:generate autogenpb --proto filetype.proto +// # go:generate go get golang.org/x/tools # repo seems broken at this time (?) +// # go:generate go install -v golang.org/x/tools/cmd/goimports //go:generate bash -c "goimports -w *.go" -- cgit v1.2.3