all: simplify and clean up

This patch modernizes the for-range-loop code to copy a map with
"maps.Clone" and "maps.Copy", also eliminates "copyFloats" with
"slices.Clone".

Also simplify "aggSort" and "sortMap" with slices and maps functions.

Signed-off-by: Jes Cok <xigua67damn@gmail.com>
This commit is contained in:
Jes Cok
2025-01-08 09:08:25 +08:00
parent 70a172696d
commit 2415c826c2
6 changed files with 26 additions and 58 deletions

View File

@ -18,6 +18,7 @@ import (
"context"
"errors"
"fmt"
"maps"
"testing"
"time"
@ -118,9 +119,7 @@ func testJWTInfo(t *testing.T, opts map[string]string) {
if opts["pub-key"] != "" && opts["priv-key"] != "" {
t.Run("verify-only", func(t *testing.T) {
newOpts := make(map[string]string, len(opts))
for k, v := range opts {
newOpts[k] = v
}
maps.Copy(newOpts, opts)
delete(newOpts, "priv-key")
verify, err := newTokenProviderJWT(lg, newOpts)
if err != nil {