Skip to content

Commit 7ace069

Browse files
committed
all: run modernize happy
$ go run golang.org/x/tools/gopls/internal/analysis/modernize/cmd/modernize@latest -fix -test ./... Signed-off-by: Koichi Shiraishi <zchee.io@gmail.com>
1 parent 76c00e3 commit 7ace069

File tree

4 files changed

+16
-20
lines changed

4 files changed

+16
-20
lines changed

AUTHORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ Kamil Dziedzic <kamil at klecza.pl>
8080
Kei Kamikawa <x00.x7f.x86 at gmail.com>
8181
Kevin Malachowski <kevin at chowski.com>
8282
Kieron Woodhouse <kieron.woodhouse at infosum.com>
83+
Koichi Shiraishi <zchee.io at gmail.com>
8384
Lance Tian <lance6716 at gmail.com>
8485
Lennart Rudolph <lrudolph at hmc.edu>
8586
Leonardo YongUk Kim <dalinaum at gmail.com>

benchmark_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ func benchmarkQuery(b *testing.B, compr bool) {
9292
defer wg.Wait()
9393
b.StartTimer()
9494

95-
for i := 0; i < concurrencyLevel; i++ {
95+
for range concurrencyLevel {
9696
go func() {
9797
for {
9898
if atomic.AddInt64(&remain, -1) < 0 {
@@ -129,7 +129,7 @@ func BenchmarkExec(b *testing.B) {
129129
b.ReportAllocs()
130130
b.ResetTimer()
131131

132-
for i := 0; i < concurrencyLevel; i++ {
132+
for range concurrencyLevel {
133133
go func() {
134134
for {
135135
if atomic.AddInt64(&remain, -1) < 0 {
@@ -345,7 +345,7 @@ func BenchmarkQueryRawBytes(b *testing.B) {
345345
for i := range blob {
346346
blob[i] = 42
347347
}
348-
for i := 0; i < 100; i++ {
348+
for i := range 100 {
349349
_, err := db.Exec("INSERT INTO bench_rawbytes VALUES (?, ?)", i, blob)
350350
if err != nil {
351351
b.Fatal(err)
@@ -404,7 +404,7 @@ func benchmark10kRows(b *testing.B, compress bool) {
404404
args[i] = sval
405405
}
406406
for i := 0; i < 10000; i += 100 {
407-
for j := 0; j < 100; j++ {
407+
for j := range 100 {
408408
args[j*2] = i + j
409409
}
410410
_, err := stmt.Exec(args...)
@@ -462,7 +462,7 @@ func BenchmarkReceiveMetadata(b *testing.B) {
462462

463463
// Create a table with 1000 integer fields
464464
createTableQuery := "CREATE TABLE large_integer_table ("
465-
for i := 0; i < 1000; i++ {
465+
for i := range 1000 {
466466
createTableQuery += fmt.Sprintf("col_%d INT", i)
467467
if i < 999 {
468468
createTableQuery += ", "

driver_test.go

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,6 @@ func runTests(t *testing.T, dsn string, tests ...func(dbt *DBTest)) {
176176
cleanupSql := "DROP TABLE IF EXISTS test"
177177

178178
for _, test := range tests {
179-
test := test
180179
t.Run("default", func(t *testing.T) {
181180
dbt := &DBTest{t, db}
182181
t.Cleanup(func() {
@@ -220,8 +219,6 @@ func runTestsParallel(t *testing.T, dsn string, tests ...func(dbt *DBTest, table
220219

221220
t.Parallel()
222221
for _, test := range tests {
223-
test := test
224-
225222
t.Run("default", func(t *testing.T) {
226223
t.Parallel()
227224

@@ -491,7 +488,6 @@ func TestMultiQuery(t *testing.T) {
491488
dbt.Error("no data")
492489
}
493490
rows.Close()
494-
495491
})
496492
}
497493

@@ -1692,7 +1688,7 @@ func TestTimezoneConversion(t *testing.T) {
16921688

16931689
// Insert local time into database (should be converted)
16941690
newYorkTz, _ := time.LoadLocation("America/New_York")
1695-
reftime := time.Date(2014, 05, 30, 18, 03, 17, 0, time.UTC).In(newYorkTz)
1691+
reftime := time.Date(2014, 0o5, 30, 18, 0o3, 17, 0, time.UTC).In(newYorkTz)
16961692
dbt.mustExec("INSERT INTO test VALUE (?)", reftime)
16971693

16981694
// Retrieve time from DB
@@ -1974,7 +1970,6 @@ func TestConcurrent(t *testing.T) {
19741970
defer wg.Done()
19751971

19761972
tx, err := dbt.db.Begin()
1977-
19781973
if err != nil {
19791974
if err.Error() != "Error 1040: Too many connections" {
19801975
fatalf("error on conn %d: %s", id, err.Error())
@@ -3051,12 +3046,12 @@ func TestRowsColumnTypes(t *testing.T) {
30513046
nfNULL := sql.NullFloat64{Float64: 0.0, Valid: false}
30523047
nf0 := sql.NullFloat64{Float64: 0.0, Valid: true}
30533048
nf1337 := sql.NullFloat64{Float64: 13.37, Valid: true}
3054-
nt0 := sql.NullTime{Time: time.Date(2006, 01, 02, 15, 04, 05, 0, time.UTC), Valid: true}
3055-
nt1 := sql.NullTime{Time: time.Date(2006, 01, 02, 15, 04, 05, 100000000, time.UTC), Valid: true}
3056-
nt2 := sql.NullTime{Time: time.Date(2006, 01, 02, 15, 04, 05, 110000000, time.UTC), Valid: true}
3057-
nt6 := sql.NullTime{Time: time.Date(2006, 01, 02, 15, 04, 05, 111111000, time.UTC), Valid: true}
3058-
nd1 := sql.NullTime{Time: time.Date(2006, 01, 02, 0, 0, 0, 0, time.UTC), Valid: true}
3059-
nd2 := sql.NullTime{Time: time.Date(2006, 03, 04, 0, 0, 0, 0, time.UTC), Valid: true}
3049+
nt0 := sql.NullTime{Time: time.Date(2006, 0o1, 0o2, 15, 0o4, 0o5, 0, time.UTC), Valid: true}
3050+
nt1 := sql.NullTime{Time: time.Date(2006, 0o1, 0o2, 15, 0o4, 0o5, 100000000, time.UTC), Valid: true}
3051+
nt2 := sql.NullTime{Time: time.Date(2006, 0o1, 0o2, 15, 0o4, 0o5, 110000000, time.UTC), Valid: true}
3052+
nt6 := sql.NullTime{Time: time.Date(2006, 0o1, 0o2, 15, 0o4, 0o5, 111111000, time.UTC), Valid: true}
3053+
nd1 := sql.NullTime{Time: time.Date(2006, 0o1, 0o2, 0, 0, 0, 0, time.UTC), Valid: true}
3054+
nd2 := sql.NullTime{Time: time.Date(2006, 0o3, 0o4, 0, 0, 0, 0, time.UTC), Valid: true}
30603055
ndNULL := sql.NullTime{Time: time.Time{}, Valid: false}
30613056
bNULL := []byte(nil)
30623057
nsNULL := sql.NullString{String: "", Valid: false}
@@ -3071,7 +3066,7 @@ func TestRowsColumnTypes(t *testing.T) {
30713066
bx0 := []byte("\x00")
30723067
bx42 := []byte("\x42")
30733068

3074-
var columns = []struct {
3069+
columns := []struct {
30753070
name string
30763071
fieldType string // type used when creating table schema
30773072
databaseTypeName string // actual type used by MySQL
@@ -3284,7 +3279,7 @@ func TestRawBytesAreNotModified(t *testing.T) {
32843279
const blobSize = defaultBufSize * 3 / 4 // Second row overwrites first row.
32853280
const insertRows = 4
32863281

3287-
var sqlBlobs = [2]string{
3282+
sqlBlobs := [2]string{
32883283
strings.Repeat(blob, blobSize/len(blob)),
32893284
strings.Repeat(strings.ToUpper(blob), blobSize/len(blob)),
32903285
}

packets.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -907,7 +907,7 @@ func (rows *textRows) readRow(dest []driver.Value) error {
907907
}
908908

909909
func (mc *mysqlConn) skipPackets(n int) error {
910-
for i := 0; i < n; i++ {
910+
for range n {
911911
if _, err := mc.readPacket(); err != nil {
912912
return err
913913
}

0 commit comments

Comments
 (0)