From f9881a61538c3273f3516d1fc37c6e81edccbda6 Mon Sep 17 00:00:00 2001 From: Eng Zer Jun Date: Mon, 27 Jan 2025 14:21:23 +0800 Subject: [PATCH] chore: replace golang.org/x/exp with stdlib (#1931) Signed-off-by: Eng Zer Jun --- go.mod | 1 - go.sum | 2 -- pkg/utils/nodepool/suite_test.go | 4 ++-- pkg/utils/pretty/pretty.go | 6 +++--- 4 files changed, 5 insertions(+), 8 deletions(-) diff --git a/go.mod b/go.mod index 259364fd36..59f8564355 100644 --- a/go.mod +++ b/go.mod @@ -66,7 +66,6 @@ require ( github.com/spf13/cobra v1.8.1 // indirect github.com/spf13/pflag v1.0.5 // indirect github.com/x448/float16 v0.8.4 // indirect - golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 golang.org/x/net v0.33.0 // indirect golang.org/x/oauth2 v0.23.0 // indirect golang.org/x/sys v0.28.0 // indirect diff --git a/go.sum b/go.sum index aed8014d0f..09eac80727 100644 --- a/go.sum +++ b/go.sum @@ -142,8 +142,6 @@ go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 h1:2dVuKD2vS7b0QIHQbpyTISPd0LeHDbnYEryqj5Q1ug8= -golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56/go.mod h1:M4RDyNAINzryxdtnbRXRL/OHtkFuWGRjvuhBJpk2IlY= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= diff --git a/pkg/utils/nodepool/suite_test.go b/pkg/utils/nodepool/suite_test.go index ead9695db5..890a865e3b 100644 --- a/pkg/utils/nodepool/suite_test.go +++ b/pkg/utils/nodepool/suite_test.go @@ -18,12 +18,12 @@ package nodepool_test import ( "context" + "math/rand/v2" "testing" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "github.com/samber/lo" - "golang.org/x/exp/rand" "sigs.k8s.io/karpenter/pkg/apis" v1 "sigs.k8s.io/karpenter/pkg/apis/v1" @@ -64,7 +64,7 @@ var _ = Describe("NodePoolUtils", func() { nps := lo.Shuffle(lo.Times(10, func(_ int) *v1.NodePool { return test.NodePool(v1.NodePool{ Spec: v1.NodePoolSpec{ - Weight: lo.ToPtr[int32](int32(rand.Intn(100) + 1)), //nolint:gosec + Weight: lo.ToPtr[int32](int32(rand.IntN(100) + 1)), //nolint:gosec }, }) })) diff --git a/pkg/utils/pretty/pretty.go b/pkg/utils/pretty/pretty.go index 009be00366..3694efdfa4 100644 --- a/pkg/utils/pretty/pretty.go +++ b/pkg/utils/pretty/pretty.go @@ -18,14 +18,14 @@ package pretty import ( "bytes" + "cmp" "encoding/json" "fmt" "regexp" + "slices" "strings" "unicode" - "golang.org/x/exp/constraints" - "golang.org/x/exp/slices" v1 "k8s.io/api/core/v1" ) @@ -55,7 +55,7 @@ func Slice[T any](s []T, maxItems int) string { // Map truncates a map after a certain number of max items to ensure that the // description in a log doesn't get too long -func Map[K constraints.Ordered, V any](values map[K]V, maxItems int) string { +func Map[K cmp.Ordered, V any](values map[K]V, maxItems int) string { var buf bytes.Buffer count := 0 var keys []K