From 1f0a18a0a8e21a831dbc002b8b4110298739b875 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Thu, 21 Nov 2024 19:00:08 -0600 Subject: [PATCH] prepare to autogen these files Signed-off-by: Jeff Carr --- machine.marshal.go | 39 ++++++++++++++++++++++++++++++++ machines.go => machine.sort.go | 0 helpers.go => package.marshal.go | 23 +------------------ packages.go => package.sort.go | 0 4 files changed, 40 insertions(+), 22 deletions(-) create mode 100644 machine.marshal.go rename machines.go => machine.sort.go (100%) rename helpers.go => package.marshal.go (66%) rename packages.go => package.sort.go (100%) diff --git a/machine.marshal.go b/machine.marshal.go new file mode 100644 index 0000000..00959cb --- /dev/null +++ b/machine.marshal.go @@ -0,0 +1,39 @@ +package zoopb + +// todo: autogen this + +import ( + "google.golang.org/protobuf/encoding/protojson" + "google.golang.org/protobuf/encoding/prototext" + "google.golang.org/protobuf/proto" +) + +// marshal to wire +func (m *Machine) Marshal() ([]byte, error) { + return proto.Marshal(m) +} + +// marshal to TEXT +func (m *Machine) MarshalTEXT() ([]byte, error) { + return prototext.Marshal(m) +} + +// marshal to JSON +func (m *Machine) MarshalJSON() ([]byte, error) { + return protojson.Marshal(m) +} + +// unmarshal from wire +func (m *Machine) Unmarshal(data []byte) error { + return proto.Unmarshal(data, m) +} + +// marshal to wire +func (m *Machines) Marshal() ([]byte, error) { + return proto.Marshal(m) +} + +// unmarshal from wire +func (m *Machines) Unmarshal(data []byte) error { + return proto.Unmarshal(data, m) +} diff --git a/machines.go b/machine.sort.go similarity index 100% rename from machines.go rename to machine.sort.go diff --git a/helpers.go b/package.marshal.go similarity index 66% rename from helpers.go rename to package.marshal.go index 390da5c..2c8a4e7 100644 --- a/helpers.go +++ b/package.marshal.go @@ -1,13 +1,12 @@ package zoopb +// todo: autogen this // functions to import and export the protobuf -// data to and from config files import ( "google.golang.org/protobuf/encoding/protojson" "google.golang.org/protobuf/encoding/prototext" "google.golang.org/protobuf/proto" - // "google.golang.org/protobuf/proto" ) // human readable JSON @@ -41,23 +40,3 @@ func (p *Packages) Marshal() ([]byte, error) { func (p *Packages) Unmarshal(data []byte) error { return proto.Unmarshal(data, p) } - -// marshal to wire -func (m *Machine) Marshal() ([]byte, error) { - return proto.Marshal(m) -} - -// unmarshal from wire -func (m *Machine) Unmarshal(data []byte) error { - return proto.Unmarshal(data, m) -} - -// marshal to wire -func (m *Machines) Marshal() ([]byte, error) { - return proto.Marshal(m) -} - -// unmarshal from wire -func (m *Machines) Unmarshal(data []byte) error { - return proto.Unmarshal(data, m) -} diff --git a/packages.go b/package.sort.go similarity index 100% rename from packages.go rename to package.sort.go