Skip to content

Commit

Permalink
fixing linting issues
Browse files Browse the repository at this point in the history
  • Loading branch information
dvilaverde committed Jun 3, 2024
1 parent 74f45e1 commit a1e459f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
4 changes: 2 additions & 2 deletions client/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ func ConnectWithDialer(ctx context.Context, network, addr, user, password, dbNam
c.charset = DEFAULT_CHARSET

// Apply configuration functions.
for i := range options {
if err := options[i](c); err != nil {
for _, option := range options {
if err := option(c); err != nil {
return nil, err
}
}
Expand Down
11 changes: 7 additions & 4 deletions driver/driver_options_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,20 @@ type mockHandler struct {

func TestDriverOptions_SetCollation(t *testing.T) {
c := &client.Conn{}
CollationOption(c, "latin2_bin")
err := CollationOption(c, "latin2_bin")
require.NoError(t, err)
require.Equal(t, "latin2_bin", c.GetCollation())
}

func TestDriverOptions_SetCompression(t *testing.T) {
var err error
c := &client.Conn{}
CompressOption(c, "true")
err = CompressOption(c, "true")
require.NoError(t, err)
require.True(t, c.HasCapability(mysql.CLIENT_COMPRESS))

CompressOption(c, "false")
err = CompressOption(c, "false")
require.NoError(t, err)
require.False(t, c.HasCapability(mysql.CLIENT_COMPRESS))

require.Error(t, CompressOption(c, "foo"))
Expand Down Expand Up @@ -200,7 +204,6 @@ func (h *mockHandler) HandleStmtPrepare(query string) (params int, columns int,
}

func (h *mockHandler) HandleStmtExecute(context interface{}, query string, args []interface{}) (*mysql.Result, error) {

if strings.HasPrefix(strings.ToLower(query), "select") {
return h.HandleQuery(query)
}
Expand Down
2 changes: 1 addition & 1 deletion mysql/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,6 @@ func NewError(errCode uint16, message string) *MyError {
func ErrorCode(errMsg string) (code int) {
var tmpStr string
// golang scanf doesn't support %*,so I used a temporary variable
fmt.Sscanf(errMsg, "%s%d", &tmpStr, &code)
_, _ = fmt.Sscanf(errMsg, "%s%d", &tmpStr, &code)
return
}

0 comments on commit a1e459f

Please sign in to comment.