add IdentifyProtobuf()

This commit is contained in:
Jeff Carr 2025-02-15 05:35:01 -06:00
parent 5c84b9ab66
commit 7900b1416e
2 changed files with 24 additions and 0 deletions

17
identify.go Normal file
View File

@ -0,0 +1,17 @@
package forgepb
import (
"go.wit.com/log"
)
// print the protobuf in human form
func IdentifyProtobuf(data []byte) error {
var pb *Identify
pb = new(Identify)
if err := pb.Unmarshal(data); err != nil {
log.Info("data can't be identified as a standard protobuf. len =", len(data))
return err
}
log.Info("Identify protobuf file uuid =", pb.Uuid, "version =", pb.Version)
return nil
}

View File

@ -4,6 +4,13 @@ package forgepb;
import "google/protobuf/timestamp.proto"; // Import the well-known type for Timestamp
// 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; //
}
message Patch {
string filename = 1; // `autogenpb:unique` `autogenpb:sort`
bytes data = 2; //