Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ jobs:
build:
strategy:
matrix:
go-version: [1.23.x, 1.25.x]
go-version: [1.25.x, 1.26.x]
platform: [windows-latest]
runs-on: ${{ matrix.platform }}
steps:
Expand All @@ -24,7 +24,7 @@ jobs:
test:
strategy:
matrix:
go-version: [1.23.x, 1.25.x]
go-version: [1.25.x, 1.26.x]
platform: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.platform }}
steps:
Expand All @@ -40,7 +40,7 @@ jobs:
verify-go-directive:
strategy:
matrix:
go-version: [1.23.x, 1.25.x]
go-version: [1.25.x, 1.26.x]
platform: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.platform }}
steps:
Expand All @@ -59,14 +59,14 @@ jobs:
- name: Install Go
uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6
with:
go-version: v1.23
go-version: v1.25
- name: Checkout code
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5
- name: Lint
uses: golangci/golangci-lint-action@55c2c1448f86e01eaae002a5a3a9624417608d84 # v6
uses: golangci/golangci-lint-action@ba0d7d2ec06a0ea1cb5fa41b2e4a3ab91d21278a # v9.3.0
with:
version: v1.60.1
args: --disable-all -v -E govet -E misspell -E gofmt -E ineffassign -E revive
version: v2.4.0
args: -v --enable-only govet,misspell,ineffassign
apidiff:
runs-on: ubuntu-latest
if: github.base_ref
Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ vet:
update-fmt:
gofmt -s -w .

# We set the maximum version of the go directive as 1.23 here
# We set the maximum version of the go directive as 1.25 here
# because the oldest go directive that exists on our supported
# release branches in k/k is 1.23.
# release branches in k/k is 1.25.
.PHONY: verify-go-directive
verify-go-directive:
./hack/verify-go-directive.sh -g 1.23
./hack/verify-go-directive.sh -g 1.25
8 changes: 4 additions & 4 deletions buffer/ring_growing_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func TestGrowthGrowing(t *testing.T) {
}

x := 10
for i := 0; i < x; i++ {
for i := range x {
if e, a := i, g.readable; e != a {
t.Fatalf("expected equal, got %#v, %#v", e, a)
}
Expand Down Expand Up @@ -133,7 +133,7 @@ func TestGrowth(t *testing.T) {
}

x := 10
for i := 0; i < x; i++ {
for i := range x {
if e, a := i, g.growing.readable; e != a {
t.Fatalf("expected equal, got %#v, %#v", e, a)
}
Expand Down Expand Up @@ -193,7 +193,7 @@ func BenchmarkTypedRingGrowing_Spike(b *testing.B) {
for i := 0; i < b.N; i++ {
buffer := NewTypedRingGrowing[int](RingGrowingOptions{InitialSize: initialSize})

for j := 0; j < spikeSize; j++ {
for j := range spikeSize {
buffer.WriteOne(j)
}

Expand All @@ -215,7 +215,7 @@ func BenchmarkRing_Spike_And_Shrink(b *testing.B) {
NormalSize: normalSize,
})

for j := 0; j < spikeSize; j++ {
for j := range spikeSize {
buffer.WriteOne(j)
}

Expand Down
4 changes: 1 addition & 3 deletions cpuset/cpuset.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,9 +210,7 @@ func Parse(s string) (CPUSet, error) {

// Split CPU list string:
// "0-5,34,46-48" => ["0-5", "34", "46-48"]
ranges := strings.Split(s, ",")

for _, r := range ranges {
for r := range strings.SplitSeq(s, ",") {
boundaries := strings.SplitN(r, "-", 2)
if len(boundaries) == 1 {
// Handle ranges that consist of only one element like "34".
Expand Down
23 changes: 10 additions & 13 deletions diff/diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func StringDiff(a, b string) string {
// ObjectDiff writes the two objects out as JSON and prints out the identical part of
// the objects followed by the remaining part of 'a' and finally the remaining part of 'b'.
// For debugging tests.
func ObjectDiff(a, b interface{}) string {
func ObjectDiff(a, b any) string {
ab, err := json.Marshal(a)
if err != nil {
panic(fmt.Sprintf("a: %v", err))
Expand All @@ -70,7 +70,7 @@ func ObjectDiff(a, b interface{}) string {
// (go's %#v formatters OTOH stop at a certain point). This is needed when you
// can't figure out why reflect.DeepEqual is returning false and nothing is
// showing you differences. This will.
func ObjectGoPrintDiff(a, b interface{}) string {
func ObjectGoPrintDiff(a, b any) string {
s := spew.ConfigState{DisableMethods: true}
return StringDiff(
s.Sprintf("%#v", a),
Expand All @@ -79,7 +79,7 @@ func ObjectGoPrintDiff(a, b interface{}) string {
}

// ObjectReflectDiff returns a diff computed through reflection, without serializing to JSON.
func ObjectReflectDiff(a, b interface{}) string {
func ObjectReflectDiff(a, b any) string {
vA, vB := reflect.ValueOf(a), reflect.ValueOf(b)
if vA.Type() != vB.Type() {
return fmt.Sprintf("type A %T and type B %T do not match", a, b)
Expand All @@ -104,7 +104,7 @@ func ObjectReflectDiff(a, b interface{}) string {
// 1. stringifies aObj and bObj
// 2. elides identical prefixes if either is too long
// 3. elides remaining content from the end if either is too long
func limit(aObj, bObj interface{}, max int) (string, string) {
func limit(aObj, bObj any, max int) (string, string) {
elidedPrefix := ""
elidedASuffix := ""
elidedBSuffix := ""
Expand Down Expand Up @@ -155,7 +155,7 @@ func public(s string) bool {

type diff struct {
path *field.Path
a, b interface{}
a, b any
}

type orderedDiffs []diff
Expand Down Expand Up @@ -186,7 +186,7 @@ func objectReflectDiff(path *field.Path, a, b reflect.Value) []diff {
}
}
return changes
case reflect.Ptr, reflect.Interface:
case reflect.Pointer, reflect.Interface:
if a.IsNil() || b.IsNil() {
switch {
case a.IsNil() && b.IsNil():
Expand All @@ -205,18 +205,15 @@ func objectReflectDiff(path *field.Path, a, b reflect.Value) []diff {
return nil
case reflect.Slice:
lA, lB := a.Len(), b.Len()
l := lA
if lB < lA {
l = lB
}
l := min(lB, lA)
if lA == lB && lA == 0 {
if a.IsNil() != b.IsNil() {
return []diff{{path: path, a: a.Interface(), b: b.Interface()}}
}
return nil
}
var diffs []diff
for i := 0; i < l; i++ {
for i := range l {
if !reflect.DeepEqual(a.Index(i), b.Index(i)) {
diffs = append(diffs, objectReflectDiff(path.Index(i), a.Index(i), b.Index(i))...)
}
Expand All @@ -232,7 +229,7 @@ func objectReflectDiff(path *field.Path, a, b reflect.Value) []diff {
if reflect.DeepEqual(a.Interface(), b.Interface()) {
return nil
}
aKeys := make(map[interface{}]interface{})
aKeys := make(map[any]any)
for _, key := range a.MapKeys() {
aKeys[key.Interface()] = a.MapIndex(key).Interface()
}
Expand Down Expand Up @@ -269,7 +266,7 @@ func objectReflectDiff(path *field.Path, a, b reflect.Value) []diff {

// ObjectGoPrintSideBySide prints a and b as textual dumps side by side,
// enabling easy visual scanning for mismatches.
func ObjectGoPrintSideBySide(a, b interface{}) string {
func ObjectGoPrintSideBySide(a, b any) string {
s := spew.ConfigState{
Indent: " ",
// Extra deep spew.
Expand Down
8 changes: 4 additions & 4 deletions diff/diff_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func TestObjectReflectDiff(t *testing.T) {
type struct1 struct{ A []int }

testCases := map[string]struct {
a, b interface{}
a, b any
out string
}{
"map": {
Expand Down Expand Up @@ -75,7 +75,7 @@ object.A:
a: []int(nil)
b: []int{}`,
},
"display type differences": {a: []interface{}{int64(1)}, b: []interface{}{uint64(1)}, out: `
"display type differences": {a: []any{int64(1)}, b: []any{uint64(1)}, out: `
object[0]:
a: 1 (int64)
b: 0x1 (uint64)`,
Expand All @@ -102,8 +102,8 @@ func TestStringDiff(t *testing.T) {

func TestLimit(t *testing.T) {
testcases := []struct {
a interface{}
b interface{}
a any
b any
expectA string
expectB string
}{
Expand Down
6 changes: 3 additions & 3 deletions dump/dump.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,16 @@ var prettyPrintConfigForHash = &spew.ConfigState{

// Pretty wrap the spew.Sdump with Indent, and disabled methods like error() and String()
// The output may change over time, so for guaranteed output please take more direct control
func Pretty(a interface{}) string {
func Pretty(a any) string {
return prettyPrintConfig.Sdump(a)
}

// ForHash keeps the original Spew.Sprintf format to ensure the same checksum
func ForHash(a interface{}) string {
func ForHash(a any) string {
return prettyPrintConfigForHash.Sprintf("%#v", a)
}

// OneLine outputs the object in one line
func OneLine(a interface{}) string {
func OneLine(a any) string {
return prettyPrintConfig.Sprintf("%#v", a)
}
12 changes: 6 additions & 6 deletions dump/dump_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func TestPretty(t *testing.T) {
tebw := embedwrap{teb, &teb}

testCases := []struct {
a interface{}
a any
want string
}{
{int8(93), "(int8) 93\n"},
Expand Down Expand Up @@ -130,7 +130,7 @@ func TestPretty(t *testing.T) {
{tebw, "(dump.embedwrap) {\n embed: (dump.embed) {\n s: (string) (len=4) \"test\"\n },\n e: (*dump.embed)({\n s: (string) (len=4) \"test\"\n })\n}\n"},
{map[string]int{}, "(map[string]int) {\n}\n"},
{map[string]int{"one": 1}, "(map[string]int) (len=1) {\n (string) (len=3) \"one\": (int) 1\n}\n"},
{map[string]interface{}{"one": 1}, "(map[string]interface {}) (len=1) {\n (string) (len=3) \"one\": (int) 1\n}\n"},
{map[string]any{"one": 1}, "(map[string]interface {}) (len=1) {\n (string) (len=3) \"one\": (int) 1\n}\n"},

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

go-spew doesn’t know about any

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ack

{map[string]customString{"key": tcs}, "(map[string]dump.customString) (len=1) {\n (string) (len=3) \"key\": (dump.customString) (len=4) \"test\"\n}\n"},
{map[string]customError{"key": tce}, "(map[string]dump.customError) (len=1) {\n (string) (len=3) \"key\": (dump.customError) 0\n}\n"},
{map[string]embed{"key": teb}, "(map[string]dump.embed) (len=1) {\n (string) (len=3) \"key\": (dump.embed) {\n s: (string) (len=4) \"test\"\n }\n}\n"},
Expand All @@ -156,7 +156,7 @@ func TestForHash(t *testing.T) {
tebw := embedwrap{teb, &teb}

testCases := []struct {
a interface{}
a any
want string
}{
{int8(93), "(int8)93"},
Expand Down Expand Up @@ -209,7 +209,7 @@ func TestForHash(t *testing.T) {
{tebw, "(dump.embedwrap){embed:(dump.embed){s:(string)test} e:(*dump.embed){s:(string)test}}"},
{map[string]int{}, "(map[string]int)map[]"},
{map[string]int{"one": 1, "two": 2}, "(map[string]int)map[one:1 two:2]"},
{map[string]interface{}{"one": 1}, "(map[string]interface {})map[one:(int)1]"},
{map[string]any{"one": 1}, "(map[string]interface {})map[one:(int)1]"},
{map[string]customString{"key": tcs}, "(map[string]dump.customString)map[key:test]"},
{map[string]customError{"key": tce}, "(map[string]dump.customError)map[key:0]"},
{map[string]embed{"key": teb}, "(map[string]dump.embed)map[key:{s:(string)test}]"},
Expand All @@ -235,7 +235,7 @@ func TestOneLine(t *testing.T) {
tebw := embedwrap{teb, &teb}

testCases := []struct {
a interface{}
a any
want string
}{
{int8(93), "(int8)93"},
Expand Down Expand Up @@ -288,7 +288,7 @@ func TestOneLine(t *testing.T) {
{tebw, "(dump.embedwrap){embed:(dump.embed){s:(string)test} e:(*dump.embed){s:(string)test}}"},
{map[string]int{}, "(map[string]int)map[]"},
{map[string]int{"one": 1}, "(map[string]int)map[one:1]"},
{map[string]interface{}{"one": 1}, "(map[string]interface {})map[one:(int)1]"},
{map[string]any{"one": 1}, "(map[string]interface {})map[one:(int)1]"},
{map[string]customString{"key": tcs}, "(map[string]dump.customString)map[key:test]"},
{map[string]customError{"key": tce}, "(map[string]dump.customError)map[key:0]"},
{map[string]embed{"key": teb}, "(map[string]dump.embed)map[key:{s:(string)test}]"},
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module k8s.io/utils

go 1.23
go 1.25

require (
github.com/davecgh/go-spew v1.1.1
Expand Down
1 change: 0 additions & 1 deletion inotify/inotify_linux.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//go:build linux
// +build linux

// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
Expand Down
1 change: 0 additions & 1 deletion inotify/inotify_linux_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//go:build linux
// +build linux

// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
Expand Down
16 changes: 8 additions & 8 deletions internal/third_party/forked/golang/golang-lru/lru.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,18 @@ type Cache struct {

// OnEvicted optionally specifies a callback function to be
// executed when an entry is purged from the cache.
OnEvicted func(key Key, value interface{})
OnEvicted func(key Key, value any)

ll *list.List
cache map[interface{}]*list.Element
cache map[any]*list.Element
}

// A Key may be any value that is comparable. See http://golang.org/ref/spec#Comparison_operators
type Key interface{}
type Key any

type entry struct {
key Key
value interface{}
value any
}

// New creates a new Cache.
Expand All @@ -48,14 +48,14 @@ func New(maxEntries int) *Cache {
return &Cache{
MaxEntries: maxEntries,
ll: list.New(),
cache: make(map[interface{}]*list.Element),
cache: make(map[any]*list.Element),
}
}

// Add adds a value to the cache.
func (c *Cache) Add(key Key, value interface{}) {
func (c *Cache) Add(key Key, value any) {
if c.cache == nil {
c.cache = make(map[interface{}]*list.Element)
c.cache = make(map[any]*list.Element)
c.ll = list.New()
}
if ee, ok := c.cache[key]; ok {
Expand All @@ -71,7 +71,7 @@ func (c *Cache) Add(key Key, value interface{}) {
}

// Get looks up a key's value from the cache.
func (c *Cache) Get(key Key) (value interface{}, ok bool) {
func (c *Cache) Get(key Key) (value any, ok bool) {
if c.cache == nil {
return
}
Expand Down
2 changes: 1 addition & 1 deletion internal/third_party/forked/golang/net/ip.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ var IPv4 = stdnet.IPv4
// Parse IPv4 address (d.d.d.d).
func parseIPv4(s string) IP {
var p [IPv4len]byte
for i := 0; i < IPv4len; i++ {
for i := range IPv4len {
if len(s) == 0 {
// Missing octets.
return nil
Expand Down
2 changes: 1 addition & 1 deletion io/read.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func consistentReadSync(filename string, attempts int, sync func(int)) ([]byte,
if err != nil {
return nil, err
}
for i := 0; i < attempts; i++ {
for i := range attempts {
if sync != nil {
sync(i)
}
Expand Down
Loading
Loading