add IdentifyProtobuf()
This commit is contained in:
parent
5c84b9ab66
commit
7900b1416e
|
@ -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
|
||||||
|
}
|
|
@ -4,6 +4,13 @@ package forgepb;
|
||||||
|
|
||||||
import "google/protobuf/timestamp.proto"; // Import the well-known type for Timestamp
|
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 {
|
message Patch {
|
||||||
string filename = 1; // `autogenpb:unique` `autogenpb:sort`
|
string filename = 1; // `autogenpb:unique` `autogenpb:sort`
|
||||||
bytes data = 2; //
|
bytes data = 2; //
|
||||||
|
|
Loading…
Reference in New Issue