Notes added by 'git notes append'
This commit is contained in:
parent
c7ee66ec32
commit
6bb60be642
|
@ -41,3 +41,108 @@ google.golang.org/protobuf v1.36.2 h1:R8FeyR1/eLmkutZOM5CWghmo5itiG9z0ktFlTVLuTm
|
||||||
google.golang.org/protobuf v1.36.2/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
|
google.golang.org/protobuf v1.36.2/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
|
||||||
|
|
||||||
// `autogen:forgeConfig.find.pb.go`
|
// `autogen:forgeConfig.find.pb.go`
|
||||||
|
|
||||||
|
// Code generated by go.wit.com/apps/autogenpb DO NOT EDIT.
|
||||||
|
// This file was autogenerated with autogenpb v0.0.40-19-gfed674d 2025.01.11_0448
|
||||||
|
// 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 forgepb
|
||||||
|
|
||||||
|
import (
|
||||||
|
"sync"
|
||||||
|
)
|
||||||
|
|
||||||
|
// a simple global lock
|
||||||
|
var forgeConfigMu sync.RWMutex
|
||||||
|
|
||||||
|
// just a simple Append() shortcut (but still uses the mutex lock)
|
||||||
|
func (x *ForgeConfigs) Append(y *ForgeConfig) {
|
||||||
|
x.Lock.Lock()
|
||||||
|
defer x.Lock.Unlock()
|
||||||
|
|
||||||
|
x.ForgeConfigs = append(x.ForgeConfigs, y)
|
||||||
|
}
|
||||||
|
|
||||||
|
// lookup a ForgeConfigs by the GoPath
|
||||||
|
func (x *ForgeConfigs) FindByGoPath(s string) *ForgeConfig {
|
||||||
|
if x == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
x.Lock.RLock()
|
||||||
|
defer x.Lock.RUnlock()
|
||||||
|
|
||||||
|
for i, _ := range x.ForgeConfigs {
|
||||||
|
if x.ForgeConfigs[i].GoPath == s {
|
||||||
|
return x.ForgeConfigs[i]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// enforces ForgeConfig.GoPath is unique in ForgeConfigs.ForgeConfigs
|
||||||
|
func (x *ForgeConfigs) AppendUniqueGoPath(newP *ForgeConfig) bool {
|
||||||
|
forgeConfigMu.Lock()
|
||||||
|
defer forgeConfigMu.Unlock()
|
||||||
|
|
||||||
|
for _, p := range x.ForgeConfigs {
|
||||||
|
if p.GoPath == newP.GoPath {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
x.ForgeConfigs = append(x.ForgeConfigs, newP)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
// enforces ForgeConfig is unique in ForgeConfigs.ForgeConfigs
|
||||||
|
func (x *ForgeConfigs) AppendUnique(newP *ForgeConfig) bool {
|
||||||
|
forgeConfigMu.Lock()
|
||||||
|
defer forgeConfigMu.Unlock()
|
||||||
|
|
||||||
|
for _, p := range x.ForgeConfigs {
|
||||||
|
if p.GoPath == newP.GoPath {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
x.ForgeConfigs = append(x.ForgeConfigs, newP)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *ForgeConfigs) DeleteByGoPath(s string) bool {
|
||||||
|
forgeConfigMu.Lock()
|
||||||
|
defer forgeConfigMu.Unlock()
|
||||||
|
|
||||||
|
for i, _ := range x.ForgeConfigs {
|
||||||
|
if x.ForgeConfigs[i].GoPath == s {
|
||||||
|
x.ForgeConfigs[i] = x.ForgeConfigs[len(x.ForgeConfigs)-1]
|
||||||
|
x.ForgeConfigs = x.ForgeConfigs[:len(x.ForgeConfigs)-1]
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
// returns an ForgeConfig if GoPath matches, otherwise create
|
||||||
|
func (x *ForgeConfigs) InsertByGoPath(y string) *ForgeConfig {
|
||||||
|
forgeConfigMu.Lock()
|
||||||
|
defer forgeConfigMu.Unlock()
|
||||||
|
|
||||||
|
for _, p := range x.ForgeConfigs {
|
||||||
|
if p.GoPath == y {
|
||||||
|
return p
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
z := new(ForgeConfig)
|
||||||
|
z.GoPath = y
|
||||||
|
x.ForgeConfigs = append(x.ForgeConfigs, z)
|
||||||
|
return z
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue