Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enabled govet #663

Merged
merged 3 commits into from
Jan 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ linters:
- nakedret
- unconvert
- whitespace
- govet
# ToDo:
#- gosimple
#- govet
#- ineffassign
#- gocritic
#- golint
Expand All @@ -26,3 +26,10 @@ linters-settings:
allow-unused: false
allow-leading-space: false
require-specific: true

govet:
enable-all: true
disable:
- fieldalignment
- lostcancel
- shadow
4 changes: 0 additions & 4 deletions canal/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,6 @@ func (c *Canal) runSyncBinlog() error {
}
}
}

return nil
}

type node struct {
Expand Down Expand Up @@ -298,8 +296,6 @@ func (c *Canal) WaitUntilPos(pos mysql.Position, timeout time.Duration) error {
}
}
}

return nil
}

func (c *Canal) GetMasterPos() (mysql.Position, error) {
Expand Down
31 changes: 15 additions & 16 deletions client/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,24 +263,23 @@ func (c *Conn) FieldList(table string, wildcard string) ([]*Field, error) {
var f *Field
if data[0] == ERR_HEADER {
return nil, c.handleErrorPacket(data)
} else {
for {
if data, err = c.ReadPacket(); err != nil {
return nil, errors.Trace(err)
}

// EOF Packet
if c.isEOFPacket(data) {
return fs, nil
}

if f, err = FieldData(data).Parse(); err != nil {
return nil, errors.Trace(err)
}
fs = append(fs, f)
}

for {
if data, err = c.ReadPacket(); err != nil {
return nil, errors.Trace(err)
}

// EOF Packet
if c.isEOFPacket(data) {
return fs, nil
}

if f, err = FieldData(data).Parse(); err != nil {
return nil, errors.Trace(err)
}
fs = append(fs, f)
}
return nil, fmt.Errorf("field list error")
}

func (c *Conn) SetAutoCommit() error {
Expand Down
1 change: 0 additions & 1 deletion client/resp.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ func (c *Conn) readUntilEOF() (err error) {
return
}
}
return
}

func (c *Conn) isEOFPacket(data []byte) bool {
Expand Down
2 changes: 0 additions & 2 deletions replication/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,4 @@ func (b *BinlogSyncer) StartBackup(backupDir string, p Position, timeout time.Du
return errors.Trace(io.ErrShortWrite)
}
}

return nil
}
2 changes: 0 additions & 2 deletions replication/json_binary.go
Original file line number Diff line number Diff line change
Expand Up @@ -391,8 +391,6 @@ func (d *jsonBinaryDecoder) decodeOpaque(data []byte) interface{} {
default:
return hack.String(data)
}

return nil
}

func (d *jsonBinaryDecoder) decodeDecimal(data []byte) interface{} {
Expand Down
32 changes: 22 additions & 10 deletions server/caching_sha2_cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,21 +192,33 @@ func (h *testCacheHandler) handleQuery(query string, binary bool) (*mysql.Result
if err != nil {
return nil, errors.Trace(err)
} else {
return &mysql.Result{0, 0, 0, 0, r}, nil
return &mysql.Result{
Status: 0,
Warnings: 0,
InsertId: 0,
AffectedRows: 0,
Resultset: r,
}, nil
}
case "insert":
return &mysql.Result{0, 0, 1, 0, nil}, nil
case "delete":
return &mysql.Result{0, 0, 0, 1, nil}, nil
case "update":
return &mysql.Result{0, 0, 0, 1, nil}, nil
case "replace":
return &mysql.Result{0, 0, 0, 1, nil}, nil
return &mysql.Result{
Status: 0,
Warnings: 0,
InsertId: 1,
AffectedRows: 0,
Resultset: nil,
}, nil
case "delete", "update", "replace":
return &mysql.Result{
Status: 0,
Warnings: 0,
InsertId: 0,
AffectedRows: 1,
Resultset: nil,
}, nil
default:
return nil, fmt.Errorf("invalid query %s", query)
}

return nil, nil
}

func (h *testCacheHandler) HandleQuery(query string) (*mysql.Result, error) {
Expand Down
2 changes: 0 additions & 2 deletions server/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,6 @@ func (c *Conn) dispatch(data []byte) interface{} {
default:
return c.h.HandleOtherCommand(cmd, data)
}

return fmt.Errorf("command %d is not handled correctly", cmd)
}

type EmptyHandler struct {
Expand Down
32 changes: 22 additions & 10 deletions server/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,21 +239,33 @@ func (h *testHandler) handleQuery(query string, binary bool) (*mysql.Result, err
if err != nil {
return nil, errors.Trace(err)
} else {
return &mysql.Result{0, 0, 0, 0, r}, nil
return &mysql.Result{
Status: 0,
Warnings: 0,
InsertId: 0,
AffectedRows: 0,
Resultset: r,
}, nil
}
case "insert":
return &mysql.Result{0, 0, 1, 0, nil}, nil
case "delete":
return &mysql.Result{0, 0, 0, 1, nil}, nil
case "update":
return &mysql.Result{0, 0, 0, 1, nil}, nil
case "replace":
return &mysql.Result{0, 0, 0, 1, nil}, nil
return &mysql.Result{
Status: 0,
Warnings: 0,
InsertId: 1,
AffectedRows: 0,
Resultset: nil,
}, nil
case "delete", "update", "replace":
return &mysql.Result{
Status: 0,
Warnings: 0,
InsertId: 0,
AffectedRows: 1,
Resultset: nil,
}, nil
default:
return nil, fmt.Errorf("invalid query %s", query)
}

return nil, nil
}

func (h *testHandler) HandleQuery(query string) (*mysql.Result, error) {
Expand Down