all: Run modernize -fix ./...

This commit is contained in:
Bjørn Erik Pedersen 2025-02-26 10:15:04 +01:00
parent b7ae24b9c2
commit 521911a576
141 changed files with 302 additions and 354 deletions

View file

@ -25,6 +25,7 @@ import (
"github.com/mitchellh/mapstructure"
"github.com/spf13/cast"
"slices"
)
var smc = newMenuCache()
@ -267,7 +268,7 @@ func (m Menu) Reverse() Menu {
// Clone clones the menu entries.
// This is for internal use only.
func (m Menu) Clone() Menu {
return append(Menu(nil), m...)
return slices.Clone(m)
}
func DecodeConfig(in any) (*config.ConfigNamespace[map[string]MenuConfig, Menus], error) {

View file

@ -14,6 +14,7 @@
package navigation
import (
"slices"
"sync"
)
@ -84,7 +85,7 @@ func (c *menuCache) getP(key string, apply func(m *Menu), menuLists ...Menu) (Me
}
m := menuLists[0]
menuCopy := append(Menu(nil), m...)
menuCopy := slices.Clone(m)
if apply != nil {
apply(&menuCopy)

View file

@ -23,7 +23,7 @@ import (
func createSortTestMenu(num int) Menu {
menu := make(Menu, num)
for i := 0; i < num; i++ {
for i := range num {
m := &MenuEntry{}
menu[i] = m
}
@ -49,11 +49,11 @@ func TestMenuCache(t *testing.T) {
var testMenuSets []Menu
for i := 0; i < 50; i++ {
for i := range 50 {
testMenuSets = append(testMenuSets, createSortTestMenu(i+1))
}
for j := 0; j < 100; j++ {
for range 100 {
wg.Add(1)
go func() {
defer wg.Done()