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
|
||||
errors := make(chan error, numReaders)
|
||||
|
||||
for i := 0; i < numReaders; i++ {
|
||||
for i := range numReaders {
|
||||
go func(id int) {
|
||||
output, err := runSecretWithEnv(map[string]string{
|
||||
"SB_SECRET_MNEMONIC": testMnemonic,
|
||||
@ -1674,7 +1674,7 @@ func test25ConcurrentOperations(t *testing.T, testMnemonic string, runSecret fun
|
||||
}
|
||||
|
||||
// Wait for all readers
|
||||
for i := 0; i < numReaders; i++ {
|
||||
for range numReaders {
|
||||
err := <-errors
|
||||
assert.NoError(t, err, "concurrent read should succeed")
|
||||
}
|
||||
|
@ -660,9 +660,9 @@ func TestConcurrentDerivation(t *testing.T) {
|
||||
results := make(chan string, testNumGoroutines*testNumIterations)
|
||||
errors := make(chan error, testNumGoroutines*testNumIterations)
|
||||
|
||||
for i := 0; i < testNumGoroutines; i++ {
|
||||
for range testNumGoroutines {
|
||||
go func() {
|
||||
for j := 0; j < testNumIterations; j++ {
|
||||
for j := range testNumIterations {
|
||||
if j < 0 || j > 1000000 {
|
||||
errors <- fmt.Errorf("index out of safe range")
|
||||
return
|
||||
@ -679,7 +679,7 @@ func TestConcurrentDerivation(t *testing.T) {
|
||||
|
||||
// Collect results
|
||||
resultMap := make(map[string]int)
|
||||
for i := 0; i < testNumGoroutines*testNumIterations; i++ {
|
||||
for range testNumGoroutines*testNumIterations {
|
||||
select {
|
||||
case result := <-results:
|
||||
resultMap[result]++
|
||||
@ -709,7 +709,7 @@ func TestConcurrentDerivation(t *testing.T) {
|
||||
|
||||
// Benchmark tests
|
||||
func BenchmarkDeriveIdentity(b *testing.B) {
|
||||
for i := 0; i < b.N; i++ {
|
||||
for i := range b.N {
|
||||
index := i % 1000
|
||||
if index < 0 || index > 1000000 {
|
||||
b.Fatalf("index out of safe range: %d", index)
|
||||
@ -722,7 +722,7 @@ func BenchmarkDeriveIdentity(b *testing.B) {
|
||||
}
|
||||
|
||||
func BenchmarkDeriveIdentityFromXPRV(b *testing.B) {
|
||||
for i := 0; i < b.N; i++ {
|
||||
for i := range b.N {
|
||||
index := i % 1000
|
||||
if index < 0 || index > 1000000 {
|
||||
b.Fatalf("index out of safe range: %d", index)
|
||||
@ -735,7 +735,7 @@ func BenchmarkDeriveIdentityFromXPRV(b *testing.B) {
|
||||
}
|
||||
|
||||
func BenchmarkDeriveEntropy(b *testing.B) {
|
||||
for i := 0; i < b.N; i++ {
|
||||
for i := range b.N {
|
||||
index := i % 1000
|
||||
if index < 0 || index > 1000000 {
|
||||
b.Fatalf("index out of safe range: %d", index)
|
||||
@ -754,7 +754,7 @@ func BenchmarkIdentityFromEntropy(b *testing.B) {
|
||||
}
|
||||
|
||||
b.ResetTimer()
|
||||
for i := 0; i < b.N; i++ {
|
||||
for range b.N {
|
||||
_, err := IdentityFromEntropy(entropy)
|
||||
if err != nil {
|
||||
b.Fatalf("identity from entropy: %v", err)
|
||||
@ -769,7 +769,7 @@ func BenchmarkEncryptDecrypt(b *testing.B) {
|
||||
}
|
||||
|
||||
b.ResetTimer()
|
||||
for i := 0; i < b.N; i++ {
|
||||
for range b.N {
|
||||
var ct bytes.Buffer
|
||||
w, err := age.Encrypt(&ct, identity.Recipient())
|
||||
if err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user