fix: convert for loops to Go 1.22+ integer range syntax (intrange)
Convert traditional for loops to use the new Go 1.22+ integer range syntax: - for i := 0; i < n; i++ → for i := range n (when index is used) - for i := 0; i < n; i++ → for range n (when index is not used) 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
9231409c5c
commit
f569bc55ea
@ -1658,7 +1658,7 @@ func test25ConcurrentOperations(t *testing.T, testMnemonic string, runSecret fun
|
|||||||
const numReaders = 5
|
const numReaders = 5
|
||||||
errors := make(chan error, numReaders)
|
errors := make(chan error, numReaders)
|
||||||
|
|
||||||
for i := 0; i < numReaders; i++ {
|
for i := range numReaders {
|
||||||
go func(id int) {
|
go func(id int) {
|
||||||
output, err := runSecretWithEnv(map[string]string{
|
output, err := runSecretWithEnv(map[string]string{
|
||||||
"SB_SECRET_MNEMONIC": testMnemonic,
|
"SB_SECRET_MNEMONIC": testMnemonic,
|
||||||
@ -1674,7 +1674,7 @@ func test25ConcurrentOperations(t *testing.T, testMnemonic string, runSecret fun
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Wait for all readers
|
// Wait for all readers
|
||||||
for i := 0; i < numReaders; i++ {
|
for range numReaders {
|
||||||
err := <-errors
|
err := <-errors
|
||||||
assert.NoError(t, err, "concurrent read should succeed")
|
assert.NoError(t, err, "concurrent read should succeed")
|
||||||
}
|
}
|
||||||
|
@ -660,9 +660,9 @@ func TestConcurrentDerivation(t *testing.T) {
|
|||||||
results := make(chan string, testNumGoroutines*testNumIterations)
|
results := make(chan string, testNumGoroutines*testNumIterations)
|
||||||
errors := make(chan error, testNumGoroutines*testNumIterations)
|
errors := make(chan error, testNumGoroutines*testNumIterations)
|
||||||
|
|
||||||
for i := 0; i < testNumGoroutines; i++ {
|
for range testNumGoroutines {
|
||||||
go func() {
|
go func() {
|
||||||
for j := 0; j < testNumIterations; j++ {
|
for j := range testNumIterations {
|
||||||
if j < 0 || j > 1000000 {
|
if j < 0 || j > 1000000 {
|
||||||
errors <- fmt.Errorf("index out of safe range")
|
errors <- fmt.Errorf("index out of safe range")
|
||||||
return
|
return
|
||||||
@ -679,7 +679,7 @@ func TestConcurrentDerivation(t *testing.T) {
|
|||||||
|
|
||||||
// Collect results
|
// Collect results
|
||||||
resultMap := make(map[string]int)
|
resultMap := make(map[string]int)
|
||||||
for i := 0; i < testNumGoroutines*testNumIterations; i++ {
|
for range testNumGoroutines*testNumIterations {
|
||||||
select {
|
select {
|
||||||
case result := <-results:
|
case result := <-results:
|
||||||
resultMap[result]++
|
resultMap[result]++
|
||||||
@ -709,7 +709,7 @@ func TestConcurrentDerivation(t *testing.T) {
|
|||||||
|
|
||||||
// Benchmark tests
|
// Benchmark tests
|
||||||
func BenchmarkDeriveIdentity(b *testing.B) {
|
func BenchmarkDeriveIdentity(b *testing.B) {
|
||||||
for i := 0; i < b.N; i++ {
|
for i := range b.N {
|
||||||
index := i % 1000
|
index := i % 1000
|
||||||
if index < 0 || index > 1000000 {
|
if index < 0 || index > 1000000 {
|
||||||
b.Fatalf("index out of safe range: %d", index)
|
b.Fatalf("index out of safe range: %d", index)
|
||||||
@ -722,7 +722,7 @@ func BenchmarkDeriveIdentity(b *testing.B) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func BenchmarkDeriveIdentityFromXPRV(b *testing.B) {
|
func BenchmarkDeriveIdentityFromXPRV(b *testing.B) {
|
||||||
for i := 0; i < b.N; i++ {
|
for i := range b.N {
|
||||||
index := i % 1000
|
index := i % 1000
|
||||||
if index < 0 || index > 1000000 {
|
if index < 0 || index > 1000000 {
|
||||||
b.Fatalf("index out of safe range: %d", index)
|
b.Fatalf("index out of safe range: %d", index)
|
||||||
@ -735,7 +735,7 @@ func BenchmarkDeriveIdentityFromXPRV(b *testing.B) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func BenchmarkDeriveEntropy(b *testing.B) {
|
func BenchmarkDeriveEntropy(b *testing.B) {
|
||||||
for i := 0; i < b.N; i++ {
|
for i := range b.N {
|
||||||
index := i % 1000
|
index := i % 1000
|
||||||
if index < 0 || index > 1000000 {
|
if index < 0 || index > 1000000 {
|
||||||
b.Fatalf("index out of safe range: %d", index)
|
b.Fatalf("index out of safe range: %d", index)
|
||||||
@ -754,7 +754,7 @@ func BenchmarkIdentityFromEntropy(b *testing.B) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
b.ResetTimer()
|
b.ResetTimer()
|
||||||
for i := 0; i < b.N; i++ {
|
for range b.N {
|
||||||
_, err := IdentityFromEntropy(entropy)
|
_, err := IdentityFromEntropy(entropy)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
b.Fatalf("identity from entropy: %v", err)
|
b.Fatalf("identity from entropy: %v", err)
|
||||||
@ -769,7 +769,7 @@ func BenchmarkEncryptDecrypt(b *testing.B) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
b.ResetTimer()
|
b.ResetTimer()
|
||||||
for i := 0; i < b.N; i++ {
|
for range b.N {
|
||||||
var ct bytes.Buffer
|
var ct bytes.Buffer
|
||||||
w, err := age.Encrypt(&ct, identity.Recipient())
|
w, err := age.Encrypt(&ct, identity.Recipient())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user