Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite67ac1f

Browse files
committed
Modernize the code for Go 1.24
Mostly done bymodernize -fix -test ./...with some minor manual edits on top.Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
1 parent1eda63c commite67ac1f

18 files changed

+19
-31
lines changed

‎devices/devicefilter_test.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99

1010
funchash(s,commstring)string {
1111
varres []string
12-
for_,l:=rangestrings.Split(s,"\n") {
12+
forl:=rangestrings.SplitSeq(s,"\n") {
1313
trimmed:=strings.TrimSpace(l)
1414
iftrimmed==""||strings.HasPrefix(trimmed,comm) {
1515
continue

‎devices/devices_emulator_test.go‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,6 @@ c 10:200 rwm`,
202202
}
203203

204204
for_,test:=rangetests {
205-
test:=test// capture range variable
206205
t.Run(test.name,func(t*testing.T) {
207206
list:=bytes.NewBufferString(test.list)
208207
emu,err:=emulatorFromList(list)
@@ -741,7 +740,6 @@ func testDeviceEmulatorApply(t *testing.T, baseDefaultAllow bool) {
741740
}
742741

743742
for_,test:=rangetests {
744-
test:=test
745743
t.Run(test.name,func(t*testing.T) {
746744
err:=test.base.Apply(test.rule)
747745
iferr!=nil&&test.expected!=nil {
@@ -1058,7 +1056,6 @@ func testDeviceEmulatorTransition(t *testing.T, sourceDefaultAllow bool) {
10581056
}
10591057

10601058
for_,test:=rangetests {
1061-
test:=test
10621059
t.Run(test.name,func(t*testing.T) {
10631060
// If we are in black-list mode, we need to prepend the relevant
10641061
// clear-all rule (the expected rule lists are written with
@@ -1130,7 +1127,7 @@ c 10:200 rwm`
11301127

11311128
varr*deviceRule
11321129
varerrerror
1133-
fori:=0;i<b.N;i++ {
1130+
forb.Loop() {
11341131
s:=bufio.NewScanner(strings.NewReader(list))
11351132
fors.Scan() {
11361133
line:=s.Text()

‎devices/systemd_test.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ func TestFindDeviceGroup(t *testing.T) {
256256
}
257257

258258
funcBenchmarkFindDeviceGroup(b*testing.B) {
259-
fori:=0;i<b.N;i++ {
259+
forb.Loop() {
260260
iferr:=testFindDeviceGroup();err!=nil {
261261
b.Fatal(err)
262262
}

‎file_test.go‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,7 @@ func BenchmarkWriteFile(b *testing.B) {
8282
"\n\n\n\n\n\n\n\n",
8383
}
8484

85-
b.ResetTimer()
86-
fori:=0;i<b.N;i++ {
85+
forb.Loop() {
8786
for_,val:=rangetc {
8887
iferr:=WriteFileByLine(dir,"file",val);err!=nil {
8988
b.Fatal(err)

‎fs/cpuacct.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ func getPercpuUsage(path string) ([]uint64, error) {
105105
iferr!=nil {
106106
returnpercpuUsage,err
107107
}
108-
for_,value:=rangestrings.Fields(data) {
108+
forvalue:=rangestrings.FieldsSeq(data) {
109109
value,err:=strconv.ParseUint(value,10,64)
110110
iferr!=nil {
111111
returnpercpuUsage,&parseError{Path:path,File:file,Err:err}

‎fs/cpuacct_test.go‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,7 @@ func BenchmarkGetCpuUsageBreakdown(b *testing.B) {
102102
"cpuacct.stat":cpuAcctStatContents,
103103
})
104104

105-
b.ResetTimer()
106-
fori:=0;i<b.N;i++ {
105+
forb.Loop() {
107106
_,_,err:=getCpuUsageBreakdown(path)
108107
iferr!=nil {
109108
b.Fatal(err)

‎fs/cpuset.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ func getCpusetStat(path string, file string) ([]uint16, error) {
8282
returnextracted,&parseError{Path:path,File:file,Err:errors.New("empty file")}
8383
}
8484

85-
for_,s:=rangestrings.Split(fileContent,",") {
85+
fors:=rangestrings.SplitSeq(fileContent,",") {
8686
fromStr,toStr,ok:=strings.Cut(s,"-")
8787
ifok {
8888
from,err:=strconv.ParseUint(fromStr,10,16)

‎fs/fs_test.go‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,7 @@ func BenchmarkGetStats(b *testing.B) {
3636

3737
varst*cgroups.Stats
3838

39-
b.ResetTimer()
40-
fori:=0;i<b.N;i++ {
39+
forb.Loop() {
4140
st,err=m.GetStats()
4241
iferr!=nil {
4342
b.Fatal(err)

‎fs2/create.go‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ func needAnyControllers(r *cgroups.Resources) (bool, error) {
2828
returnfalse,err
2929
}
3030
avail:=make(map[string]struct{})
31-
for_,ctr:=rangestrings.Fields(content) {
31+
forctr:=rangestrings.FieldsSeq(content) {
3232
avail[ctr]=struct{}{}
3333
}
3434

@@ -137,8 +137,7 @@ func CreateCgroupPath(path string, c *cgroups.Cgroup) (Err error) {
137137
ifi<len(elements)-1 {
138138
iferr:=cgroups.WriteFile(current,cgStCtlFile,res);err!=nil {
139139
// try write one by one
140-
allCtrs:=strings.Split(res," ")
141-
for_,ctr:=rangeallCtrs {
140+
forctr:=rangestrings.SplitSeq(res," ") {
142141
_=cgroups.WriteFile(current,cgStCtlFile,ctr)
143142
}
144143
}

‎fscommon/utils.go‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,7 @@ func GetValueByKey(path, file, key string) (uint64, error) {
8282
}
8383

8484
key+=" "
85-
lines:=strings.Split(content,"\n")
86-
for_,line:=rangelines {
85+
forline:=rangestrings.SplitSeq(content,"\n") {
8786
v,ok:=strings.CutPrefix(line,key)
8887
ifok {
8988
val,err:=ParseUint(v,10,64)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp