Skip to content

Commit d2f6004

Browse files
committed
use staticcheck
1 parent d3e4fe6 commit d2f6004

File tree

7 files changed

+16
-10
lines changed

7 files changed

+16
-10
lines changed

.github/workflows/test.yml

+6
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ 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/[email protected]
19+
1420
list:
1521
runs-on: ubuntu-latest
1622
outputs:

auth.go

+1-1
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.go

+1-3
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,7 @@ func DeregisterDialContext(net string) {
6060
dialsLock.Lock()
6161
defer dialsLock.Unlock()
6262
if dials != nil {
63-
if _, ok := dials[net]; ok {
64-
delete(dials, net)
65-
}
63+
delete(dials, net)
6664
}
6765
}
6866

driver_test.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -347,8 +347,8 @@ func TestMultiQuery(t *testing.T) {
347347
rows := dbt.mustQuery("SELECT value FROM test WHERE id=1;")
348348
if rows.Next() {
349349
rows.Scan(&out)
350-
if 5 != out {
351-
dbt.Errorf("5 != %d", out)
350+
if out != 5 {
351+
dbt.Errorf("expected 5, got %d", out)
352352
}
353353

354354
if rows.Next() {
@@ -1402,6 +1402,7 @@ func TestReuseClosedConnection(t *testing.T) {
14021402
if err != nil {
14031403
t.Fatalf("error preparing statement: %s", err.Error())
14041404
}
1405+
//lint:ignore SA1019 this is a test
14051406
_, err = stmt.Exec(nil)
14061407
if err != nil {
14071408
t.Fatalf("error executing statement: %s", err.Error())
@@ -1416,6 +1417,7 @@ func TestReuseClosedConnection(t *testing.T) {
14161417
t.Errorf("panic after reusing a closed connection: %v", err)
14171418
}
14181419
}()
1420+
//lint:ignore SA1019 this is a test
14191421
_, err = stmt.Exec(nil)
14201422
if err != nil && err != driver.ErrBadConn {
14211423
t.Errorf("unexpected error '%s', expected '%s'",

errors.go

+1-1
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

+2-2
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,10 @@ func (mc *mysqlConn) 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

+1-1
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)