Skip to content

Commit

Permalink
*: tidy code,make code more go style. (#12300)
Browse files Browse the repository at this point in the history
  • Loading branch information
xiekeyi98 authored and zz-jason committed Sep 23, 2019
1 parent 06629d6 commit e086686
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 11 deletions.
4 changes: 2 additions & 2 deletions cmd/ddltest/index_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ func (s *TestDDLSuite) checkAddIndex(c *C, indexInfo *model.IndexInfo) {
}

func (s *TestDDLSuite) checkDropIndex(c *C, indexInfo *model.IndexInfo) {
gc_worker, err := gcworker.NewMockGCWorker(s.store.(tikv.Storage))
gcWorker, err := gcworker.NewMockGCWorker(s.store.(tikv.Storage))
c.Assert(err, IsNil)
err = gc_worker.DeleteRanges(goctx.Background(), uint64(math.MaxInt32))
err = gcWorker.DeleteRanges(goctx.Background(), uint64(math.MaxInt32))
c.Assert(err, IsNil)

ctx := s.ctx
Expand Down
2 changes: 1 addition & 1 deletion ddl/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ func (w *worker) onRecoverTable(d *ddlCtx, t *meta.Meta, job *model.Job) (ver in

// mockRecoverTableCommitErrOnce uses to make sure
// `mockRecoverTableCommitErr` only mock error once.
var mockRecoverTableCommitErrOnce uint32 = 0
var mockRecoverTableCommitErrOnce uint32

func enableGC(w *worker) error {
ctx, err := w.sessPool.get()
Expand Down
2 changes: 1 addition & 1 deletion expression/builtin_time.go
Original file line number Diff line number Diff line change
Expand Up @@ -2168,7 +2168,7 @@ func (b *builtinTimeSig) evalDuration(row chunk.Row) (res types.Duration, isNull
fsp = len(expr) - idx - 1
}

tmpFsp := int8(0)
var tmpFsp int8
if tmpFsp, err = types.CheckFsp(fsp); err != nil {
return res, isNull, err
}
Expand Down
6 changes: 4 additions & 2 deletions store/tikv/client_batch.go
Original file line number Diff line number Diff line change
Expand Up @@ -418,8 +418,10 @@ func (a *batchConn) batchSendLoop(cfg config.TiKVClient) {

func (a *batchConn) getClientAndSend(entries []*batchCommandsEntry, requests []*tikvpb.BatchCommandsRequest_Request, requestIDs []uint64) {
// Choose a connection by round-robbin.
var cli *batchCommandsClient = nil
var target string = ""
var (
cli *batchCommandsClient
target string
)
for i := 0; i < len(a.batchCommandsClients); i++ {
a.index = (a.index + 1) % uint32(len(a.batchCommandsClients))
target = a.batchCommandsClients[a.index].target
Expand Down
12 changes: 7 additions & 5 deletions store/tikv/gcworker/gc_worker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ package gcworker
import (
"bytes"
"context"
"github.com/pingcap/tidb/kv"
"github.com/pingcap/tidb/store/tikv/oracle"
"math"
"sort"
"strconv"
Expand All @@ -30,15 +28,17 @@ import (
"github.com/pingcap/kvproto/pkg/errorpb"
"github.com/pingcap/kvproto/pkg/kvrpcpb"
"github.com/pingcap/kvproto/pkg/metapb"
"github.com/pingcap/pd/client"
pd "github.com/pingcap/pd/client"
"github.com/pingcap/tidb/config"
"github.com/pingcap/tidb/ddl/util"
"github.com/pingcap/tidb/domain"
"github.com/pingcap/tidb/kv"
"github.com/pingcap/tidb/session"
"github.com/pingcap/tidb/store/mockoracle"
"github.com/pingcap/tidb/store/mockstore"
"github.com/pingcap/tidb/store/mockstore/mocktikv"
"github.com/pingcap/tidb/store/tikv"
"github.com/pingcap/tidb/store/tikv/oracle"
"github.com/pingcap/tidb/store/tikv/tikvrpc"
)

Expand Down Expand Up @@ -470,8 +470,10 @@ func (s *testGCWorkerSuite) testDeleteRangesFailureImpl(c *C, failType int) {
sendReqCh := make(chan SentReq, 20)

// The request sent to the specified key and store wil fail.
var failKey []byte = nil
var failStore *metapb.Store = nil
var (
failKey []byte
failStore *metapb.Store
)
s.client.unsafeDestroyRangeHandler = func(addr string, req *tikvrpc.Request) (*tikvrpc.Response, error) {
sendReqCh <- SentReq{req, addr}
resp := &tikvrpc.Response{
Expand Down

0 comments on commit e086686

Please sign in to comment.