Skip to content

Commit 2f4b14c

Browse files
authored
Update supported Go versions. (#755)
* Update minimum supported version to 1.24.0. * Update CI tests for latest Go versions. * Run Go modernize. Signed-off-by: SuperQ <[email protected]>
1 parent ab5187b commit 2f4b14c

19 files changed

+40
-60
lines changed

.circleci/config.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ version: 2.1
44
jobs:
55
lint:
66
docker:
7-
- image: cimg/go:1.24
7+
- image: cimg/go:1.25
88
steps:
99
- checkout
1010
- run: make check_license
@@ -46,14 +46,14 @@ workflows:
4646
matrix:
4747
parameters:
4848
go_version:
49-
- "1.23"
5049
- "1.24"
50+
- "1.25"
5151
- test:
5252
name: test-windows
5353
os: windows
5454
run_test: false
5555
matrix:
5656
parameters:
5757
go_version:
58-
- "1.23"
5958
- "1.24"
59+
- "1.25"

blockdevice/stats.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -425,8 +425,7 @@ func (fs FS) SysBlockDeviceQueueStats(device string) (BlockQueueStats, error) {
425425
return BlockQueueStats{}, err
426426
}
427427
var schedulers []string
428-
xs := strings.Split(scheduler, " ")
429-
for _, s := range xs {
428+
for s := range strings.SplitSeq(scheduler, " ") {
430429
if strings.HasPrefix(s, "[") && strings.HasSuffix(s, "]") {
431430
s = s[1 : len(s)-1]
432431
stat.SchedulerCurrent = s

buddyinfo.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ func parseBuddyInfo(r io.Reader) ([]BuddyInfo, error) {
7171
}
7272

7373
sizes := make([]float64, arraySize)
74-
for i := 0; i < arraySize; i++ {
74+
for i := range arraySize {
7575
sizes[i], err = strconv.ParseFloat(parts[i+4], 64)
7676
if err != nil {
7777
return nil, fmt.Errorf("%w: Invalid valid in buddyinfo: %f: %w", ErrFileParse, sizes[i], err)

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/prometheus/procfs
22

3-
go 1.23.0
3+
go 1.24.0
44

55
require (
66
github.com/google/go-cmp v0.7.0

mountinfo.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,7 @@ func mountOptionsParseOptionalFields(o []string) (map[string]string, error) {
147147
// mountOptionsParser parses the mount options, superblock options.
148148
func mountOptionsParser(mountOptions string) map[string]string {
149149
opts := make(map[string]string)
150-
options := strings.Split(mountOptions, ",")
151-
for _, opt := range options {
150+
for opt := range strings.SplitSeq(mountOptions, ",") {
152151
splitOption := strings.Split(opt, "=")
153152
if len(splitOption) < 2 {
154153
key := splitOption[0]

mountstats.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ func parseMountStatsNFS(s *bufio.Scanner, statVersion string) (*MountStatsNFS, e
383383
if stats.Opts == nil {
384384
stats.Opts = map[string]string{}
385385
}
386-
for _, opt := range strings.Split(ss[1], ",") {
386+
for opt := range strings.SplitSeq(ss[1], ",") {
387387
split := strings.Split(opt, "=")
388388
if len(split) == 2 {
389389
stats.Opts[split[0]] = split[1]

net_protocols.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ func (pc *NetProtocolCapabilities) parseCapabilities(capabilities []string) erro
169169
&pc.EnterMemoryPressure,
170170
}
171171

172-
for i := 0; i < len(capabilities); i++ {
172+
for i := range capabilities {
173173
switch capabilities[i] {
174174
case "y":
175175
*capabilityFields[i] = true

net_sockstat.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,6 @@ func parseSockstatKVs(kvs []string) (map[string]int, error) {
139139
func parseSockstatProtocol(kvs map[string]int) NetSockstatProtocol {
140140
var nsp NetSockstatProtocol
141141
for k, v := range kvs {
142-
// Capture the range variable to ensure we get unique pointers for
143-
// each of the optional fields.
144-
v := v
145142
switch k {
146143
case "inuse":
147144
nsp.InUse = v

net_unix_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ func testNetUNIX(t *testing.T, testInode bool, got *NetUNIX) {
108108
// Enable the fixtures to be used for multiple tests by clearing the inode
109109
// field when appropriate.
110110
if !testInode {
111-
for i := 0; i < len(want); i++ {
111+
for i := range want {
112112
want[i].Inode = 0
113113
}
114114
}

proc_maps64_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ func BenchmarkParseAddress(b *testing.B) {
147147
s, e uintptr
148148
err error
149149
)
150-
for i := 0; i < b.N; i++ {
150+
for b.Loop() {
151151
s, e, err = parseAddresses("7f7d7469e000-7f7d746a0000")
152152
if err != nil {
153153
b.Fatal(err)
@@ -166,7 +166,7 @@ func BenchmarkParseDevice(b *testing.B) {
166166
d uint64
167167
err error
168168
)
169-
for i := 0; i < b.N; i++ {
169+
for b.Loop() {
170170
d, err = parseDevice("00:22")
171171
if err != nil {
172172
b.Fatal(err)

0 commit comments

Comments
 (0)