diff options
| author | Jeff Carr <[email protected]> | 2024-11-15 17:25:11 -0600 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2024-11-15 17:25:11 -0600 |
| commit | 5ef3669e7d35d6b281e2c4b5972fa9958c30f74c (patch) | |
| tree | 1553423b3495b218e9bd5536f98e04bc0e9c0993 /helpers.go | |
| parent | eacbb1fb7af28656b269b8bdc287f67a88e4f233 (diff) | |
stub in sort function
Signed-off-by: Jeff Carr <[email protected]>
Diffstat (limited to 'helpers.go')
| -rw-r--r-- | helpers.go | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/helpers.go b/helpers.go new file mode 100644 index 0000000..93d0a73 --- /dev/null +++ b/helpers.go @@ -0,0 +1,32 @@ +package zoopb + +// 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" +) + +// human readable JSON +func (p *Packages) FormatJSON() string { + return protojson.Format(p) +} + +// 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 (p *Packages) FormatTEXT() string { + return prototext.Format(p) +} + +// marshal +func (p *Packages) MarshalJSON() ([]byte, error) { + return protojson.Marshal(p) +} + +// unmarshal +func (p *Packages) UnmarshalJSON(data []byte) error { + return protojson.Unmarshal(data, p) +} |
