From 5bd4dab6e939f9512cca4ba30bf777869efb7145 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Sat, 14 Dec 2024 15:24:56 -0600 Subject: [PATCH] Notes added by 'git notes append' --- 5673e2cc2e82206cf4c864dd1b56538895fe6a6e | 58 ++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/5673e2cc2e82206cf4c864dd1b56538895fe6a6e b/5673e2cc2e82206cf4c864dd1b56538895fe6a6e index 4b9fb93..a85b6b8 100644 --- a/5673e2cc2e82206cf4c864dd1b56538895fe6a6e +++ b/5673e2cc2e82206cf4c864dd1b56538895fe6a6e @@ -39,3 +39,61 @@ google.golang.org/protobuf v1.35.2 h1:8Ar7bF+apOIoThw1EdZl0p1oWvMqTHmpA2fRTyZO8i google.golang.org/protobuf v1.35.2/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= // `autogen:forgeConfig.marshal.pb.go` + +package forgepb + +// This file was autogenerated with autogenpb. +// go install go.wit.com/apps/autogenpb@latest +// +// You can use it on simple protobuf files +// The .proto file must have a singular and plural form of a message +// (for those of you that know ruby on rails, it's like that) +// +// You can mark which repos you want to auto generate sort.pb.go and marshal.pb.go files for +// +// For an example, +// go-clone go.wit.com/lib/protobuf/gitpb +// + +import ( + "google.golang.org/protobuf/encoding/protojson" + "google.golang.org/protobuf/encoding/prototext" + "google.golang.org/protobuf/proto" +) + +// human readable JSON +func (v *ForgeConfigs) FormatJSON() string { + return protojson.Format(v) +} + +// marshal json +func (v *ForgeConfigs) MarshalJSON() ([]byte, error) { + return protojson.Marshal(v) +} + +// unmarshal json +func (v *ForgeConfigs) UnmarshalJSON(data []byte) error { + return protojson.Unmarshal(data, v) +} + +// apparently this isn't stable, but it's awesomely better +// https://protobuf.dev/reference/go/faq/#unstable-text +// it's so great for config files, I'm using it by default to try to fix the problems with it +func (v *ForgeConfigs) FormatTEXT() string { + return prototext.Format(v) +} + +// unmarshalTEXT. This reads the .text config file back in after the user edits it +func (v *ForgeConfigs) UnmarshalTEXT(data []byte) error { + return prototext.Unmarshal(data, v) +} + +// marshal to wire. This is called winning. +func (v *ForgeConfigs) Marshal() ([]byte, error) { + return proto.Marshal(v) +} + +// unmarshal from wire. You have won. +func (v *ForgeConfigs) Unmarshal(data []byte) error { + return proto.Unmarshal(data, v) +}