From dc640a6ccb70fa15a7d0cf3132aa0d484ea3b0f4 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Fri, 29 Nov 2024 11:56:57 -0600 Subject: autogen the marshal file Signed-off-by: Jeff Carr --- blah_marshal | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 blah_marshal (limited to 'blah_marshal') diff --git a/blah_marshal b/blah_marshal new file mode 100644 index 0000000..738ae35 --- /dev/null +++ b/blah_marshal @@ -0,0 +1,42 @@ +package gitpb + +// todo: autogen this +// functions to import and export the protobuf + +import ( + "google.golang.org/protobuf/encoding/protojson" + "google.golang.org/protobuf/encoding/prototext" + "google.golang.org/protobuf/proto" +) + +// human readable JSON +func (r *Repo) FormatJSON() string { + return protojson.Format(r) +} + +// apparently this isn't supposed to be used? +// https://protobuf.dev/reference/go/faq/#unstable-text +// this is a shame because this is much nicer output than JSON Format() +func (r *Repo) FormatTEXT() string { + return prototext.Format(r) +} + +// marshal json +func (r *Repo) MarshalJSON() ([]byte, error) { + return protojson.Marshal(r) +} + +// unmarshal +func (r *Repo) UnmarshalJSON(data []byte) error { + return protojson.Unmarshal(data, r) +} + +// marshal to wire +func (r *Repo) Marshal() ([]byte, error) { + return proto.Marshal(r) +} + +// unmarshal from wire +func (r *Repo) Unmarshal(data []byte) error { + return proto.Unmarshal(data, r) +} -- cgit v1.2.3