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

Commit 564dee9

Browse files
authored
CI: use staticcheck (#1449)
1 parent 943264b commit 564dee9

File tree

6 files changed

+20
-9
lines changed

6 files changed

+20
-9
lines changed

‎.github/workflows/test.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,14 @@ env:
1111
MYSQL_TEST_CONCURRENT: 1
1212

1313
jobs:
14+
lint:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v3
18+
- uses: dominikh/staticcheck-action@v1.3.0
19+
with:
20+
version: "2023年1月3日"
21+
1422
list:
1523
runs-on: ubuntu-latest
1624
outputs:

‎auth.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ func (mc *mysqlConn) handleAuthResult(oldAuthData []byte, plugin string) error {
382382
// parse public key
383383
block, rest := pem.Decode(data[1:])
384384
if block == nil {
385-
return fmt.Errorf("No Pem data found, data: %s", rest)
385+
return fmt.Errorf("no pem data found, data: %s", rest)
386386
}
387387
pkix, err := x509.ParsePKIXPublicKey(block.Bytes)
388388
if err != nil {

‎driver_test.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -346,8 +346,8 @@ func TestMultiQuery(t *testing.T) {
346346
rows := dbt.mustQuery("SELECT value FROM test WHERE id=1;")
347347
if rows.Next() {
348348
rows.Scan(&out)
349-
if 5 != out {
350-
dbt.Errorf("5 != %d", out)
349+
if out != 5 {
350+
dbt.Errorf("expected 5, got %d", out)
351351
}
352352

353353
if rows.Next() {
@@ -1293,7 +1293,7 @@ func TestLoadData(t *testing.T) {
12931293
_, err = dbt.db.Exec("LOAD DATA LOCAL INFILE 'Reader::doesnotexist' INTO TABLE test")
12941294
if err == nil {
12951295
dbt.Fatal("load non-existent Reader didn't fail")
1296-
} else if err.Error() != "Reader 'doesnotexist' is not registered" {
1296+
} else if err.Error() != "reader 'doesnotexist' is not registered" {
12971297
dbt.Fatal(err.Error())
12981298
}
12991299
})
@@ -1401,6 +1401,7 @@ func TestReuseClosedConnection(t *testing.T) {
14011401
if err != nil {
14021402
t.Fatalf("error preparing statement: %s", err.Error())
14031403
}
1404+
//lint:ignore SA1019 this is a test
14041405
_, err = stmt.Exec(nil)
14051406
if err != nil {
14061407
t.Fatalf("error executing statement: %s", err.Error())
@@ -1415,6 +1416,7 @@ func TestReuseClosedConnection(t *testing.T) {
14151416
t.Errorf("panic after reusing a closed connection: %v", err)
14161417
}
14171418
}()
1419+
//lint:ignore SA1019 this is a test
14181420
_, err = stmt.Exec(nil)
14191421
if err != nil && err != driver.ErrBadConn {
14201422
t.Errorf("unexpected error '%s', expected '%s'",
@@ -2432,6 +2434,7 @@ func TestExecMultipleResults(t *testing.T) {
24322434
t.Fatalf("failed to connect: %v", err)
24332435
}
24342436
conn.Raw(func(conn interface{}) error {
2437+
//lint:ignore SA1019 this is a test
24352438
ex := conn.(driver.Execer)
24362439
res, err := ex.Exec(`
24372440
INSERT INTO test (value) VALUES ('a'), ('b');
@@ -2489,8 +2492,8 @@ func TestQueryMultipleResults(t *testing.T) {
24892492
t.Fatalf("failed to connect: %v", err)
24902493
}
24912494
conn.Raw(func(conn interface{}) error {
2495+
//lint:ignore SA1019 this is a test
24922496
qr := conn.(driver.Queryer)
2493-
24942497
c := conn.(*mysqlConn)
24952498

24962499
// Demonstrate that repeated queries reset the affectedRows

‎errors.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ var (
2121
ErrMalformPkt = errors.New("malformed packet")
2222
ErrNoTLS = errors.New("TLS requested but server does not support TLS")
2323
ErrCleartextPassword = errors.New("this user requires clear text authentication. If you still want to use it, please add 'allowCleartextPasswords=1' to your DSN")
24-
ErrNativePassword = errors.New("this user requires mysql native password authentication.")
24+
ErrNativePassword = errors.New("this user requires mysql native password authentication")
2525
ErrOldPassword = errors.New("this user requires old password authentication. If you still want to use it, please add 'allowOldPasswords=1' to your DSN. See also https://github.com/go-sql-driver/mysql/wiki/old_passwords")
2626
ErrUnknownPlugin = errors.New("this authentication plugin is not supported")
2727
ErrOldProtocol = errors.New("MySQL server does not support required protocol 41+")

‎infile.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,10 @@ func (mc *okHandler) handleInFileRequest(name string) (err error) {
116116
defer deferredClose(&err, cl)
117117
}
118118
} else {
119-
err = fmt.Errorf("Reader '%s' is <nil>", name)
119+
err = fmt.Errorf("reader '%s' is <nil>", name)
120120
}
121121
} else {
122-
err = fmt.Errorf("Reader '%s' is not registered", name)
122+
err = fmt.Errorf("reader '%s' is not registered", name)
123123
}
124124
} else { // File
125125
name = strings.Trim(name, `"`)

‎nulltime.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ func (nt *NullTime) Scan(value interface{}) (err error) {
5959
}
6060

6161
nt.Valid = false
62-
return fmt.Errorf("Can't convert %T to time.Time", value)
62+
return fmt.Errorf("can't convert %T to time.Time", value)
6363
}
6464

6565
// Value implements the driver Valuer interface.

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /