new patches .proto

This commit is contained in:
Jeff Carr 2025-09-23 10:22:55 -05:00
parent fabf425958
commit bc58c0d02f
5 changed files with 1904 additions and 0 deletions

93
file.marshal.pb.go Normal file
View File

@ -0,0 +1,93 @@
// Code generated by go.wit.com/apps/autogenpb DO NOT EDIT.
// This file was autogenerated with autogenpb v0.5.3 2025-09-13_13:40:21_UTC
// go install go.wit.com/apps/autogenpb@latest
//
// define which structs (messages) you want to use in the .proto file
// Then sort.pb.go and marshal.pb.go files are autogenerated
//
// autogenpb uses it and has an example .proto file with instructions
//
package main
import (
"google.golang.org/protobuf/encoding/protojson"
"google.golang.org/protobuf/encoding/prototext"
"google.golang.org/protobuf/proto"
)
// human readable JSON
func (v *Files) FormatJSON() string {
return protojson.Format(v)
}
// marshal json
func (v *Files) MarshalJSON() ([]byte, error) {
return protojson.Marshal(v)
}
// unmarshal json
func (v *Files) 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 brilliant for config files!
func (v *Files) FormatTEXT() string {
v.fixUuid()
return prototext.Format(v)
}
// unmarshalTEXT. This reads the .text config file back in after the user edits it
func (v *Files) UnmarshalTEXT(data []byte) error {
return prototext.Unmarshal(data, v)
}
// marshal to wire. This is called winning.
func (v *Files) Marshal() ([]byte, error) {
v.fixUuid()
return proto.Marshal(v)
}
// unmarshal from wire. You have won.
func (v *Files) Unmarshal(data []byte) error {
return proto.Unmarshal(data, v)
}
// human readable JSON
func (v *Identify) FormatJSON() string {
return protojson.Format(v)
}
// marshal json
func (v *Identify) MarshalJSON() ([]byte, error) {
return protojson.Marshal(v)
}
// unmarshal json
func (v *Identify) 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 brilliant for config files!
func (v *Identify) FormatTEXT() string {
return prototext.Format(v)
}
// unmarshalTEXT. This reads the .text config file back in after the user edits it
func (v *Identify) UnmarshalTEXT(data []byte) error {
return prototext.Unmarshal(data, v)
}
// marshal to wire. This is called winning.
func (v *Identify) Marshal() ([]byte, error) {
return proto.Marshal(v)
}
// unmarshal from wire. You have won.
func (v *Identify) Unmarshal(data []byte) error {
return proto.Unmarshal(data, v)
}

1222
file.pb.go Normal file

File diff suppressed because it is too large Load Diff

539
file.sort.pb.go Normal file
View File

@ -0,0 +1,539 @@
// Code generated by go.wit.com/apps/autogenpb DO NOT EDIT.
// This file was autogenerated with autogenpb v0.5.3 2025-09-13_13:40:21_UTC
// go install go.wit.com/apps/autogenpb@latest
//
// define which structs (messages) you want to use in the .proto file
// Then sort.pb.go and marshal.pb.go files are autogenerated
//
// autogenpb uses it and has an example .proto file with instructions
//
package main
import (
"fmt"
"iter"
"sync"
"google.golang.org/protobuf/proto"
)
// a simple global lock
var fileMu sync.RWMutex
func (x *Files) fixUuid() {
if x == nil {
return
}
if x.Uuid == "6c9ae4dd-648d-4b51-9738-bd59fb8fafd5" {
return
}
x.Uuid = "6c9ae4dd-648d-4b51-9738-bd59fb8fafd5"
x.Version = "v0.0.38 go.wit.com/apps/autogenpb"
}
func NewFiles() *Files {
x := new(Files)
x.Uuid = "6c9ae4dd-648d-4b51-9738-bd59fb8fafd5"
x.Version = "v0.0.38 go.wit.com/apps/autogenpb"
return x
}
// START SORT
// DEFINE THE Files SCANNER.
// itializes a new scanner.
func newFilesScanner(things []*Files) *FilesScanner {
return &FilesScanner{things: things}
}
type FilesScanner struct {
sync.Mutex
things []*Files
index int
}
func (it *FilesScanner) Scan() bool {
if it.index >= len(it.things) {
return false
}
it.Lock()
it.index++
it.Unlock()
return true
}
// Next() returns the next thing in the array
func (it *FilesScanner) Next() *Files {
if it.things[it.index-1] == nil {
fmt.Println("Next() error in FilesScanner", it.index)
}
return it.things[it.index-1]
}
// END DEFINE THE SCANNER
// DEFINE THE File SCANNER.
// itializes a new scanner.
func newFileScanner(things []*File) *FileScanner {
return &FileScanner{things: things}
}
type FileScanner struct {
sync.Mutex
things []*File
index int
}
func (it *FileScanner) Scan() bool {
if it.index >= len(it.things) {
return false
}
it.Lock()
it.index++
it.Unlock()
return true
}
// Next() returns the next thing in the array
func (it *FileScanner) Next() *File {
if it.things[it.index-1] == nil {
fmt.Println("Next() error in FileScanner", it.index)
}
return it.things[it.index-1]
}
// END DEFINE THE SCANNER
// DEFINE THE MsgVar SCANNER.
// itializes a new scanner.
func newMsgVarScanner(things []*MsgVar) *MsgVarScanner {
return &MsgVarScanner{things: things}
}
type MsgVarScanner struct {
sync.Mutex
things []*MsgVar
index int
}
func (it *MsgVarScanner) Scan() bool {
if it.index >= len(it.things) {
return false
}
it.Lock()
it.index++
it.Unlock()
return true
}
// Next() returns the next thing in the array
func (it *MsgVarScanner) Next() *MsgVar {
if it.things[it.index-1] == nil {
fmt.Println("Next() error in MsgVarScanner", it.index)
}
return it.things[it.index-1]
}
// END DEFINE THE SCANNER
// DEFINE THE MsgName SCANNER.
// itializes a new scanner.
func newMsgNameScanner(things []*MsgName) *MsgNameScanner {
return &MsgNameScanner{things: things}
}
type MsgNameScanner struct {
sync.Mutex
things []*MsgName
index int
}
func (it *MsgNameScanner) Scan() bool {
if it.index >= len(it.things) {
return false
}
it.Lock()
it.index++
it.Unlock()
return true
}
// Next() returns the next thing in the array
func (it *MsgNameScanner) Next() *MsgName {
if it.things[it.index-1] == nil {
fmt.Println("Next() error in MsgNameScanner", it.index)
}
return it.things[it.index-1]
}
// END DEFINE THE SCANNER
// DEFINE THE Sort SCANNER.
// itializes a new scanner.
func newSortScanner(things []*Sort) *SortScanner {
return &SortScanner{things: things}
}
type SortScanner struct {
sync.Mutex
things []*Sort
index int
}
func (it *SortScanner) Scan() bool {
if it.index >= len(it.things) {
return false
}
it.Lock()
it.index++
it.Unlock()
return true
}
// Next() returns the next thing in the array
func (it *SortScanner) Next() *Sort {
if it.things[it.index-1] == nil {
fmt.Println("Next() error in SortScanner", it.index)
}
return it.things[it.index-1]
}
// END DEFINE THE SCANNER
// DEFINE THE FormatMsg SCANNER.
// itializes a new scanner.
func newFormatMsgScanner(things []*FormatMsg) *FormatMsgScanner {
return &FormatMsgScanner{things: things}
}
type FormatMsgScanner struct {
sync.Mutex
things []*FormatMsg
index int
}
func (it *FormatMsgScanner) Scan() bool {
if it.index >= len(it.things) {
return false
}
it.Lock()
it.index++
it.Unlock()
return true
}
// Next() returns the next thing in the array
func (it *FormatMsgScanner) Next() *FormatMsg {
if it.things[it.index-1] == nil {
fmt.Println("Next() error in FormatMsgScanner", it.index)
}
return it.things[it.index-1]
}
// END DEFINE THE SCANNER
// DEFINE THE Find SCANNER.
// itializes a new scanner.
func newFindScanner(things []*Find) *FindScanner {
return &FindScanner{things: things}
}
type FindScanner struct {
sync.Mutex
things []*Find
index int
}
func (it *FindScanner) Scan() bool {
if it.index >= len(it.things) {
return false
}
it.Lock()
it.index++
it.Unlock()
return true
}
// Next() returns the next thing in the array
func (it *FindScanner) Next() *Find {
if it.things[it.index-1] == nil {
fmt.Println("Next() error in FindScanner", it.index)
}
return it.things[it.index-1]
}
// END DEFINE THE SCANNER
// DEFINE THE Identify SCANNER.
// itializes a new scanner.
func newIdentifyScanner(things []*Identify) *IdentifyScanner {
return &IdentifyScanner{things: things}
}
type IdentifyScanner struct {
sync.Mutex
things []*Identify
index int
}
func (it *IdentifyScanner) Scan() bool {
if it.index >= len(it.things) {
return false
}
it.Lock()
it.index++
it.Unlock()
return true
}
// Next() returns the next thing in the array
func (it *IdentifyScanner) Next() *Identify {
if it.things[it.index-1] == nil {
fmt.Println("Next() error in IdentifyScanner", it.index)
}
return it.things[it.index-1]
}
// END DEFINE THE SCANNER
// safely returns a slice of pointers to the FRUIT protobufs
func (x *Files) allFiles() []*File {
x.RLock()
defer x.RUnlock()
// Create a new slice to hold pointers to each FRUIT
var tmp []*File
tmp = make([]*File, len(x.Files))
for i, p := range x.Files {
tmp[i] = p // Copy pointers for safe iteration
}
return tmp
}
// safely returns a slice of pointers to the FRUIT protobufs
func (x *File) allMsgNames() []*MsgName {
x.RLock()
defer x.RUnlock()
// Create a new slice to hold pointers to each FRUIT
var tmp []*MsgName
tmp = make([]*MsgName, len(x.MsgNames))
for i, p := range x.MsgNames {
tmp[i] = p // Copy pointers for safe iteration
}
return tmp
}
// safely returns a slice of pointers to the FRUIT protobufs
func (x *File) allSortNames() []*MsgName {
x.RLock()
defer x.RUnlock()
// Create a new slice to hold pointers to each FRUIT
var tmp []*MsgName
tmp = make([]*MsgName, len(x.SortNames))
for i, p := range x.SortNames {
tmp[i] = p // Copy pointers for safe iteration
}
return tmp
}
// safely returns a slice of pointers to the FRUIT protobufs
func (x *File) allToSort() []*Sort {
x.RLock()
defer x.RUnlock()
// Create a new slice to hold pointers to each FRUIT
var tmp []*Sort
tmp = make([]*Sort, len(x.ToSort))
for i, p := range x.ToSort {
tmp[i] = p // Copy pointers for safe iteration
}
return tmp
}
// safely returns a slice of pointers to the FRUIT protobufs
func (x *MsgName) allVars() []*MsgVar {
x.RLock()
defer x.RUnlock()
// Create a new slice to hold pointers to each FRUIT
var tmp []*MsgVar
tmp = make([]*MsgVar, len(x.Vars))
for i, p := range x.Vars {
tmp[i] = p // Copy pointers for safe iteration
}
return tmp
}
// safely returns a slice of pointers to the FRUIT protobufs
func (x *FormatMsg) allMsgs() []*FormatMsg {
x.RLock()
defer x.RUnlock()
// Create a new slice to hold pointers to each FRUIT
var tmp []*FormatMsg
tmp = make([]*FormatMsg, len(x.Msgs))
for i, p := range x.Msgs {
tmp[i] = p // Copy pointers for safe iteration
}
return tmp
}
// safely returns a slice of pointers to the File protobufs
func (x *Files) selectAllFiles() []*File {
x.RLock()
defer x.RUnlock()
// Create a new slice to hold pointers to each File
var tmp []*File
tmp = make([]*File, len(x.Files))
for i, p := range x.Files {
tmp[i] = p // Copy pointers for safe iteration
}
return tmp
}
// safely returns a slice of pointers to the MsgName protobufs
func (x *File) selectAllMsgNames() []*MsgName {
x.RLock()
defer x.RUnlock()
// Create a new slice to hold pointers to each MsgName
var tmp []*MsgName
tmp = make([]*MsgName, len(x.MsgNames))
for i, p := range x.MsgNames {
tmp[i] = p // Copy pointers for safe iteration
}
return tmp
}
// safely returns a slice of pointers to the MsgName protobufs
func (x *File) selectAllSortNames() []*MsgName {
x.RLock()
defer x.RUnlock()
// Create a new slice to hold pointers to each MsgName
var tmp []*MsgName
tmp = make([]*MsgName, len(x.SortNames))
for i, p := range x.SortNames {
tmp[i] = p // Copy pointers for safe iteration
}
return tmp
}
// safely returns a slice of pointers to the Sort protobufs
func (x *File) selectAllToSort() []*Sort {
x.RLock()
defer x.RUnlock()
// Create a new slice to hold pointers to each Sort
var tmp []*Sort
tmp = make([]*Sort, len(x.ToSort))
for i, p := range x.ToSort {
tmp[i] = p // Copy pointers for safe iteration
}
return tmp
}
// safely returns a slice of pointers to the MsgVar protobufs
func (x *MsgName) selectAllVars() []*MsgVar {
x.RLock()
defer x.RUnlock()
// Create a new slice to hold pointers to each MsgVar
var tmp []*MsgVar
tmp = make([]*MsgVar, len(x.Vars))
for i, p := range x.Vars {
tmp[i] = p // Copy pointers for safe iteration
}
return tmp
}
// safely returns a slice of pointers to the FormatMsg protobufs
func (x *FormatMsg) selectAllMsgs() []*FormatMsg {
x.RLock()
defer x.RUnlock()
// Create a new slice to hold pointers to each FormatMsg
var tmp []*FormatMsg
tmp = make([]*FormatMsg, len(x.Msgs))
for i, p := range x.Msgs {
tmp[i] = p // Copy pointers for safe iteration
}
return tmp
}
// END SORT
func (x *Files) Len() int {
x.RLock()
defer x.RUnlock()
return len(x.Files)
}
// a Append() shortcut (that does Clone() with a mutex) notsure if it really works
func (x *Files) Append(y *File) *File {
x.Lock()
defer x.Unlock()
z := proto.Clone(y).(*File)
x.Files = append(x.Files, z)
return z
}
func (x *Files) All() *FileScanner {
FilePointers := x.selectAllFiles()
scanner := newFileScanner(FilePointers)
return scanner
}
// Iterate 'for x := range' syntax using the awesome golang 1.24 'iter'
func (x *Files) IterAll() iter.Seq[*File] {
items := x.selectAllFiles()
// log.Println("Made All() Iter.Seq[] with length", len(items))
return func(yield func(*File) bool) {
for _, v := range items {
if !yield(v) {
return
}
}
}
}
func (x *Files) Delete(y *File) bool {
x.Lock()
defer x.Unlock()
for i, _ := range x.Files {
if x.Files[i] == y {
x.Files[i] = x.Files[len(x.Files)-1]
x.Files = x.Files[:len(x.Files)-1]
return true
}
}
return false
}

18
go.mod Normal file
View File

@ -0,0 +1,18 @@
module go.wit.com/apps/autogenpb
go 1.24.1
require (
github.com/go-cmd/cmd v1.4.3
go.wit.com/dev/alexflint/arg v1.6.3
go.wit.com/lib/fhelp v0.0.23
go.wit.com/lib/gui/shell v0.22.33
go.wit.com/log v0.25.1
golang.org/x/text v0.29.0
google.golang.org/protobuf v1.36.9
)
require (
github.com/alexflint/go-scalar v1.2.0 // indirect
github.com/google/uuid v1.6.0 // indirect
)

32
go.sum Normal file
View File

@ -0,0 +1,32 @@
github.com/alexflint/go-scalar v1.2.0 h1:WR7JPKkeNpnYIOfHRa7ivM21aWAdHD0gEWHCx+WQBRw=
github.com/alexflint/go-scalar v1.2.0/go.mod h1:LoFvNMqS1CPrMVltza4LvnGKhaSpc3oyLEBUZVhhS2o=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/go-cmd/cmd v1.4.3 h1:6y3G+3UqPerXvPcXvj+5QNPHT02BUw7p6PsqRxLNA7Y=
github.com/go-cmd/cmd v1.4.3/go.mod h1:u3hxg/ry+D5kwh8WvUkHLAMe2zQCaXd00t35WfQaOFk=
github.com/go-test/deep v1.1.0 h1:WOcxcdHcvdgThNXjw0t76K42FXTU7HpNQWHpA2HHNlg=
github.com/go-test/deep v1.1.0/go.mod h1:5C2ZWiW0ErCdrYzpqxLbTX7MG14M9iiw8DgHncVwcsE=
github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
go.wit.com/dev/alexflint/arg v1.6.3 h1:EduPl3oA/Sk4XcBVM7EYERlHjvbyEDysK5PqI/Wmdtw=
go.wit.com/dev/alexflint/arg v1.6.3/go.mod h1:RKOrAnxFl+856vbfvMEYcdd4qgBq2ZEO8atUcINendY=
go.wit.com/lib/fhelp v0.0.23 h1:XWQLxxS603xQwJ5IKjCKQ5vNeiivh3jfVrmDdc5piJ8=
go.wit.com/lib/fhelp v0.0.23/go.mod h1:8lRn3kJUuxkhief0JjbxL/ydw06ZJx/HLw7eMx9Xx9Y=
go.wit.com/lib/gui/shell v0.22.33 h1:3MvWBQU4rOHK4Ac5MkQ62ndW7WhCBpu9F3AVeUF7YgQ=
go.wit.com/lib/gui/shell v0.22.33/go.mod h1:aRDwKXKXkZaO4y/0KPe1lhKQCXpyi8hXgUEOrHhzpAI=
go.wit.com/log v0.25.1 h1:74WVf9NSN6z5jc2oSbA1ehxdZ7V/NBXTk5t0jIoaTMg=
go.wit.com/log v0.25.1/go.mod h1:XE4lTfAibWgwBJksIk7u3IEJ8xcBvNhnlewYAQGj2Ew=
golang.org/x/text v0.29.0 h1:1neNs90w9YzJ9BocxfsQNHKuAT4pkghyXc4nhZ6sJvk=
golang.org/x/text v0.29.0/go.mod h1:7MhJOA9CD2qZyOKYazxdYMF85OwPdEr9jTtBpO7ydH4=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/protobuf v1.36.9 h1:w2gp2mA27hUeUzj9Ex9FBjsBm40zfaDtEWow293U7Iw=
google.golang.org/protobuf v1.36.9/go.mod h1:fuxRtAxBytpl4zzqUh6/eyUujkJdNiuEkXntxiD/uRU=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=