Skip to content

Commit

Permalink
use staticcheck
Browse files Browse the repository at this point in the history
  • Loading branch information
methane committed Jun 15, 2023
1 parent d3e4fe6 commit d2f6004
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 10 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ env:
MYSQL_TEST_CONCURRENT: 1

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: dominikh/staticcheck-action@v1.3.0

list:
runs-on: ubuntu-latest
outputs:
Expand Down
2 changes: 1 addition & 1 deletion auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ func (mc *mysqlConn) handleAuthResult(oldAuthData []byte, plugin string) error {
// parse public key
block, rest := pem.Decode(data[1:])
if block == nil {
return fmt.Errorf("No Pem data found, data: %s", rest)
return fmt.Errorf("no pem data found, data: %s", rest)
}
pkix, err := x509.ParsePKIXPublicKey(block.Bytes)
if err != nil {
Expand Down
4 changes: 1 addition & 3 deletions driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,7 @@ func DeregisterDialContext(net string) {
dialsLock.Lock()
defer dialsLock.Unlock()
if dials != nil {
if _, ok := dials[net]; ok {
delete(dials, net)
}
delete(dials, net)
}
}

Expand Down
6 changes: 4 additions & 2 deletions driver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -347,8 +347,8 @@ func TestMultiQuery(t *testing.T) {
rows := dbt.mustQuery("SELECT value FROM test WHERE id=1;")
if rows.Next() {
rows.Scan(&out)
if 5 != out {
dbt.Errorf("5 != %d", out)
if out != 5 {
dbt.Errorf("expected 5, got %d", out)
}

if rows.Next() {
Expand Down Expand Up @@ -1402,6 +1402,7 @@ func TestReuseClosedConnection(t *testing.T) {
if err != nil {
t.Fatalf("error preparing statement: %s", err.Error())
}
//lint:ignore SA1019 this is a test
_, err = stmt.Exec(nil)
if err != nil {
t.Fatalf("error executing statement: %s", err.Error())
Expand All @@ -1416,6 +1417,7 @@ func TestReuseClosedConnection(t *testing.T) {
t.Errorf("panic after reusing a closed connection: %v", err)
}
}()
//lint:ignore SA1019 this is a test
_, err = stmt.Exec(nil)
if err != nil && err != driver.ErrBadConn {
t.Errorf("unexpected error '%s', expected '%s'",
Expand Down
2 changes: 1 addition & 1 deletion errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ var (
ErrMalformPkt = errors.New("malformed packet")
ErrNoTLS = errors.New("TLS requested but server does not support TLS")
ErrCleartextPassword = errors.New("this user requires clear text authentication. If you still want to use it, please add 'allowCleartextPasswords=1' to your DSN")
ErrNativePassword = errors.New("this user requires mysql native password authentication.")
ErrNativePassword = errors.New("this user requires mysql native password authentication")
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")
ErrUnknownPlugin = errors.New("this authentication plugin is not supported")
ErrOldProtocol = errors.New("MySQL server does not support required protocol 41+")
Expand Down
4 changes: 2 additions & 2 deletions infile.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,10 @@ func (mc *mysqlConn) handleInFileRequest(name string) (err error) {
defer deferredClose(&err, cl)
}
} else {
err = fmt.Errorf("Reader '%s' is <nil>", name)
err = fmt.Errorf("reader '%s' is <nil>", name)
}
} else {
err = fmt.Errorf("Reader '%s' is not registered", name)
err = fmt.Errorf("reader '%s' is not registered", name)
}
} else { // File
name = strings.Trim(name, `"`)
Expand Down
2 changes: 1 addition & 1 deletion nulltime.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func (nt *NullTime) Scan(value interface{}) (err error) {
}

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

// Value implements the driver Valuer interface.
Expand Down

0 comments on commit d2f6004

Please sign in to comment.