From 2f582e2e33b2bae06e136bd2a547a934a6700074 Mon Sep 17 00:00:00 2001 From: kim <89579420+NyaaaWhatsUpDoc@users.noreply.github.com> Date: Fri, 27 Sep 2024 10:26:50 +0000 Subject: [PATCH] update gruf / {go-cache, go-maps, go-kv} (#3361) --- go.mod | 6 +++--- go.sum | 12 +++++------ .../codeberg.org/gruf/go-cache/v3/README.md | 6 ------ .../codeberg.org/gruf/go-kv/format/format.go | 6 ++++-- vendor/codeberg.org/gruf/go-kv/format/util.go | 5 ----- vendor/codeberg.org/gruf/go-maps/common.go | 20 +++++++++++-------- vendor/modules.txt | 12 +++++------ 7 files changed, 31 insertions(+), 36 deletions(-) diff --git a/go.mod b/go.mod index d404415a0..49da997b5 100644 --- a/go.mod +++ b/go.mod @@ -8,13 +8,13 @@ require ( codeberg.org/gruf/go-bytes v1.0.2 codeberg.org/gruf/go-bytesize v1.0.3 codeberg.org/gruf/go-byteutil v1.3.0 - codeberg.org/gruf/go-cache/v3 v3.5.7 + codeberg.org/gruf/go-cache/v3 v3.6.1 codeberg.org/gruf/go-debug v1.3.0 codeberg.org/gruf/go-errors/v2 v2.3.2 codeberg.org/gruf/go-fastcopy v1.1.3 codeberg.org/gruf/go-ffmpreg v0.2.6 codeberg.org/gruf/go-iotools v0.0.0-20240710125620-934ae9c654cf - codeberg.org/gruf/go-kv v1.6.4 + codeberg.org/gruf/go-kv v1.6.5 codeberg.org/gruf/go-list v0.0.0-20240425093752-494db03d641f codeberg.org/gruf/go-mempool v0.0.0-20240507125005-cef10d64a760 codeberg.org/gruf/go-mimetypes v1.2.0 @@ -87,7 +87,7 @@ require ( require ( codeberg.org/gruf/go-fastpath/v2 v2.0.0 // indirect codeberg.org/gruf/go-mangler v1.4.1 // indirect - codeberg.org/gruf/go-maps v1.0.3 // indirect + codeberg.org/gruf/go-maps v1.0.4 // indirect github.com/Masterminds/goutils v1.1.1 // indirect github.com/Masterminds/semver/v3 v3.2.1 // indirect github.com/Masterminds/sprig/v3 v3.2.3 // indirect diff --git a/go.sum b/go.sum index 92e1d964f..25086eed5 100644 --- a/go.sum +++ b/go.sum @@ -36,8 +36,8 @@ codeberg.org/gruf/go-bytesize v1.0.3 h1:Tz8tCxhPLeyM5VryuBNjUHgKmLj4Bx9RbPaUSA3q codeberg.org/gruf/go-bytesize v1.0.3/go.mod h1:n/GU8HzL9f3UNp/mUKyr1qVmTlj7+xacpp0OHfkvLPs= codeberg.org/gruf/go-byteutil v1.3.0 h1:nRqJnCcRQ7xbfU6azw7zOzJrSMDIJHBqX6FL9vEMYmU= codeberg.org/gruf/go-byteutil v1.3.0/go.mod h1:chgnZz1LUcfaObaIFglxF5MRYQkJGjQf4WwVz95ccCM= -codeberg.org/gruf/go-cache/v3 v3.5.7 h1:5hut49a8Wp3hdwrCEJYj6pHY2aRR1hyTmkK4+wHVYq4= -codeberg.org/gruf/go-cache/v3 v3.5.7/go.mod h1:Thahfuf3PgHSv2+1zHpvhRdX97tx1WXurVNGWpZucAM= +codeberg.org/gruf/go-cache/v3 v3.6.1 h1:sY1XhYeskjZAuYeMm5R0o4Qymru5taNbzmZPSn1oXLE= +codeberg.org/gruf/go-cache/v3 v3.6.1/go.mod h1:JUNjc4E8gRccn3t+B99akxURFrU6NTDkvFVcwiZirnw= codeberg.org/gruf/go-debug v1.3.0 h1:PIRxQiWUFKtGOGZFdZ3Y0pqyfI0Xr87j224IYe2snZs= codeberg.org/gruf/go-debug v1.3.0/go.mod h1:N+vSy9uJBQgpQcJUqjctvqFz7tBHJf+S/PIjLILzpLg= codeberg.org/gruf/go-errors/v2 v2.3.2 h1:8ItWaOMfhDaqrJK1Pw8MO0Nu+o/tVcQtR5cJ58Vc4zo= @@ -50,16 +50,16 @@ codeberg.org/gruf/go-ffmpreg v0.2.6 h1:OHlTOF+62/b+VeM3Svg7praweU/NECRIsuhilZLFa codeberg.org/gruf/go-ffmpreg v0.2.6/go.mod h1:sViRI0BYK2B8PJw4BrOg7DquPD71mZjDfffRAFcDtvk= codeberg.org/gruf/go-iotools v0.0.0-20240710125620-934ae9c654cf h1:84s/ii8N6lYlskZjHH+DG6jyia8w2mXMZlRwFn8Gs3A= codeberg.org/gruf/go-iotools v0.0.0-20240710125620-934ae9c654cf/go.mod h1:zZAICsp5rY7+hxnws2V0ePrWxE0Z2Z/KXcN3p/RQCfk= -codeberg.org/gruf/go-kv v1.6.4 h1:3NZiW8HVdBM3kpOiLb7XfRiihnzZWMAixdCznguhILk= -codeberg.org/gruf/go-kv v1.6.4/go.mod h1:O/YkSvKiS9XsRolM3rqCd9YJmND7dAXu9z+PrlYO4bc= +codeberg.org/gruf/go-kv v1.6.5 h1:ttPf0NA8F79pDqBttSudPTVCZmGncumeNIxmeM9ztz0= +codeberg.org/gruf/go-kv v1.6.5/go.mod h1:c4PsGqw05bDScvISpK+d31SiDEpBorweCL50hsiK3dc= codeberg.org/gruf/go-list v0.0.0-20240425093752-494db03d641f h1:Ss6Z+vygy+jOGhj96d/GwsYYDd22QmIcH74zM7/nQkw= codeberg.org/gruf/go-list v0.0.0-20240425093752-494db03d641f/go.mod h1:F9pl4h34iuVN7kucKam9fLwsItTc+9mmaKt7pNXRd/4= codeberg.org/gruf/go-loosy v0.0.0-20231007123304-bb910d1ab5c4 h1:IXwfoU7f2whT6+JKIKskNl/hBlmWmnF1vZd84Eb3cyA= codeberg.org/gruf/go-loosy v0.0.0-20231007123304-bb910d1ab5c4/go.mod h1:fiO8HE1wjZCephcYmRRsVnNI/i0+mhy44Z5dQalS0rM= codeberg.org/gruf/go-mangler v1.4.1 h1:Dv58jFfy9On49L11ji6tpADUknwoJA46iaiZvnNXecs= codeberg.org/gruf/go-mangler v1.4.1/go.mod h1:mDmW8Ia352RvNFaXoP9K60TgcmCZJtX0j6wm3vjAsJE= -codeberg.org/gruf/go-maps v1.0.3 h1:VDwhnnaVNUIy5O93CvkcE2IZXnMB1+IJjzfop9V12es= -codeberg.org/gruf/go-maps v1.0.3/go.mod h1:D5LNDxlC9rsDuVQVM6JObaVGAdHB6g2dTdOdkh1aXWA= +codeberg.org/gruf/go-maps v1.0.4 h1:K+Ww4vvR3TZqm5jqrKVirmguZwa3v1VUvmig2SE8uxY= +codeberg.org/gruf/go-maps v1.0.4/go.mod h1:ASX7osM7kFwt5O8GfGflcFjrwYGD8eIuRLl/oMjhEi8= codeberg.org/gruf/go-mempool v0.0.0-20240507125005-cef10d64a760 h1:m2/UCRXhjDwAg4vyji6iKCpomKw6P4PmBOUi5DvAMH4= codeberg.org/gruf/go-mempool v0.0.0-20240507125005-cef10d64a760/go.mod h1:E3RcaCFNq4zXpvaJb8lfpPqdUAmSkP5F1VmMiEUYTEk= codeberg.org/gruf/go-mimetypes v1.2.0 h1:3rZGXY/SkNYbamiddWXs2gETXIBkGIeWYnbWpp2OEbc= diff --git a/vendor/codeberg.org/gruf/go-cache/v3/README.md b/vendor/codeberg.org/gruf/go-cache/v3/README.md index eb298bea4..ffc516a70 100644 --- a/vendor/codeberg.org/gruf/go-cache/v3/README.md +++ b/vendor/codeberg.org/gruf/go-cache/v3/README.md @@ -9,9 +9,3 @@ A `cache.Cache{}` implementation with much more of the inner workings exposed. D ## ttl A `cache.TTLCache{}` implementation with much more of the inner workings exposed. Designed to be used as a base for your own customizations, or used as-is. - -## result - -`result.Cache` is an example of a more complex cache implementation using `ttl.Cache{}` as its underpinning. - -It provides caching specifically of loadable struct types, with automatic keying by multiple different field members and caching of negative (error) values. All useful when wrapping, for example, a database. \ No newline at end of file diff --git a/vendor/codeberg.org/gruf/go-kv/format/format.go b/vendor/codeberg.org/gruf/go-kv/format/format.go index 5027c7c06..cd0b574ea 100644 --- a/vendor/codeberg.org/gruf/go-kv/format/format.go +++ b/vendor/codeberg.org/gruf/go-kv/format/format.go @@ -197,7 +197,8 @@ func (f format) AppendBytes(b []byte) { // Quoted only if spaces/requires escaping case f.Key(): - f.AppendStringSafe(b2s(b)) + s := byteutil.B2S(b) + f.AppendStringSafe(s) // Append as separate ASCII quoted bytes in slice case f.Verbose(): @@ -214,7 +215,8 @@ func (f format) AppendBytes(b []byte) { // Quoted only if spaces/requires escaping case f.Value(): - f.AppendStringSafe(b2s(b)) + s := byteutil.B2S(b) + f.AppendStringSafe(s) // Append as raw bytes default: diff --git a/vendor/codeberg.org/gruf/go-kv/format/util.go b/vendor/codeberg.org/gruf/go-kv/format/util.go index 79cb30981..dbb918952 100644 --- a/vendor/codeberg.org/gruf/go-kv/format/util.go +++ b/vendor/codeberg.org/gruf/go-kv/format/util.go @@ -98,8 +98,3 @@ func isNil(i interface{}) bool { type eface struct{ _type, data unsafe.Pointer } //nolint return (*(*eface)(unsafe.Pointer(&i))).data == nil //nolint } - -// b2s converts a byteslice to string without allocation. -func b2s(b []byte) string { - return *(*string)(unsafe.Pointer(&b)) -} diff --git a/vendor/codeberg.org/gruf/go-maps/common.go b/vendor/codeberg.org/gruf/go-maps/common.go index f5877ee3a..0c92b41a2 100644 --- a/vendor/codeberg.org/gruf/go-maps/common.go +++ b/vendor/codeberg.org/gruf/go-maps/common.go @@ -17,7 +17,7 @@ type ordered[K comparable, V any] struct { } // write_check panics if map is not in a safe-state to write to. -func (m ordered[K, V]) write_check() { +func (m *ordered[K, V]) write_check() { if m.rnly { panic("map write during read loop") } @@ -54,15 +54,17 @@ func (m *ordered[K, V]) Delete(key K) bool { // Range passes given function over the requested range of the map. func (m *ordered[K, V]) Range(start, length int, fn func(int, K, V)) { + // Nil check + if fn == nil { + panic("nil func") + } + // Disallow writes m.rnly = true defer func() { m.rnly = false }() - // Nil check - _ = fn - switch end := start + length; { // No loop to iterate case length == 0: @@ -104,15 +106,17 @@ func (m *ordered[K, V]) Range(start, length int, fn func(int, K, V)) { // RangeIf passes given function over the requested range of the map. Returns early on 'fn' -> false. func (m *ordered[K, V]) RangeIf(start, length int, fn func(int, K, V) bool) { + // Nil check + if fn == nil { + panic("nil func") + } + // Disallow writes m.rnly = true defer func() { m.rnly = false }() - // Nil check - _ = fn - switch end := start + length; { // No loop to iterate case length == 0: @@ -163,8 +167,8 @@ func (m *ordered[K, V]) Truncate(sz int, fn func(K, V)) { panic("index out of bounds") } + // Nil check if fn == nil { - // move nil check out of loop fn = func(K, V) {} } diff --git a/vendor/modules.txt b/vendor/modules.txt index aadcc4893..c59a7e1a5 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -7,8 +7,8 @@ codeberg.org/gruf/go-bytesize # codeberg.org/gruf/go-byteutil v1.3.0 ## explicit; go 1.20 codeberg.org/gruf/go-byteutil -# codeberg.org/gruf/go-cache/v3 v3.5.7 -## explicit; go 1.19 +# codeberg.org/gruf/go-cache/v3 v3.6.1 +## explicit; go 1.20 codeberg.org/gruf/go-cache/v3 codeberg.org/gruf/go-cache/v3/simple codeberg.org/gruf/go-cache/v3/ttl @@ -31,8 +31,8 @@ codeberg.org/gruf/go-ffmpreg/embed/ffprobe # codeberg.org/gruf/go-iotools v0.0.0-20240710125620-934ae9c654cf ## explicit; go 1.21 codeberg.org/gruf/go-iotools -# codeberg.org/gruf/go-kv v1.6.4 -## explicit; go 1.19 +# codeberg.org/gruf/go-kv v1.6.5 +## explicit; go 1.20 codeberg.org/gruf/go-kv codeberg.org/gruf/go-kv/format # codeberg.org/gruf/go-list v0.0.0-20240425093752-494db03d641f @@ -41,8 +41,8 @@ codeberg.org/gruf/go-list # codeberg.org/gruf/go-mangler v1.4.1 ## explicit; go 1.19 codeberg.org/gruf/go-mangler -# codeberg.org/gruf/go-maps v1.0.3 -## explicit; go 1.19 +# codeberg.org/gruf/go-maps v1.0.4 +## explicit; go 1.20 codeberg.org/gruf/go-maps # codeberg.org/gruf/go-mempool v0.0.0-20240507125005-cef10d64a760 ## explicit; go 1.22.2