Skip to content

Commit

Permalink
feat: fix format
Browse files Browse the repository at this point in the history
  • Loading branch information
georgehao committed Dec 25, 2021
1 parent eedc576 commit 0ae562c
Show file tree
Hide file tree
Showing 15 changed files with 26 additions and 28 deletions.
3 changes: 1 addition & 2 deletions cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,14 @@ import (

import (
"github.com/pkg/errors"

"github.com/spf13/cobra"
)

import (
"github.com/dubbogo/arana/pkg/config"
"github.com/dubbogo/arana/pkg/constants"
"github.com/dubbogo/arana/pkg/executor"
filter "github.com/dubbogo/arana/pkg/filters"
"github.com/dubbogo/arana/pkg/filters"
"github.com/dubbogo/arana/pkg/mysql"
"github.com/dubbogo/arana/pkg/proto"
"github.com/dubbogo/arana/pkg/resource"
Expand Down
2 changes: 0 additions & 2 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import (

import (
"github.com/ghodss/yaml"

"github.com/pkg/errors"
)

Expand Down Expand Up @@ -146,7 +145,6 @@ func parse(path string) *Configuration {
}
}
return cfg

}

func yamlFormat(path string) bool {
Expand Down
6 changes: 4 additions & 2 deletions pkg/constants/mysql/collations.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@

package mysql

const DefaultCollation = "utf8mb4_general_ci"
const BinaryCollation = "binary"
const (
DefaultCollation = "utf8mb4_general_ci"
BinaryCollation = "binary"
)

// A list of available Collations mapped to the internal ID.
// To update this map use the following MySQL query:
Expand Down
2 changes: 1 addition & 1 deletion pkg/constants/mysql/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ const (
// ComSetOption is COM_SET_OPTION
ComSetOption = 0x1b

//ComStmtFetch is COM_STMT_FETCH
// ComStmtFetch is COM_STMT_FETCH
ComStmtFetch = 0x1c

ComDaemon = 0x1d
Expand Down
2 changes: 1 addition & 1 deletion pkg/executor/redirect.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ func (executor *RedirectExecutor) doPostFilter(ctx *proto.Context, result proto.

func generateSql(stmt *proto.Stmt) (string, error) {
var result []byte
var j = 0
j := 0
sql := []byte(stmt.PrepareStmt)
for i := 0; i < len(sql); i++ {
if sql[i] != '?' {
Expand Down
2 changes: 1 addition & 1 deletion pkg/mysql/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ func (conn *BackendConnection) handleAuthResult(oldAuthData []byte, plugin strin
} else {
pubKey := conn.conf.pubKey
if pubKey == nil {
//request public key from server
// request public key from server
var data []byte
if err = conn.c.writePacket([]byte{cachingSha2PasswordRequestPublicKey}); err != nil {
return err
Expand Down
10 changes: 4 additions & 6 deletions pkg/mysql/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,7 @@ func (conn *BackendConnection) parseInitialHandshakePacket(data []byte) (uint32,
if !ok {
return 0, nil, "", err2.NewSQLError(mysql.CRMalformedPacket, mysql.SSUnknownSQLState, "parseInitialHandshakePacket: packet has no capability flags (lower 2 bytes)")
}
var capabilities = uint32(capLower)
capabilities := uint32(capLower)

// The packet can end here.
if pos == len(data) {
Expand Down Expand Up @@ -942,9 +942,9 @@ func (conn *BackendConnection) readColumnDefinition(field *Field, index int) err
}
field.decimals = decimals

//if more Content, command was field list
// if more Content, command was field list
if len(colDef) > pos+8 {
//length of default value lenenc-int
// length of default value lenenc-int
field.defaultValueLength, pos, ok = readUint64(colDef, pos)
if !ok {
return err2.NewSQLError(mysql.CRMalformedPacket, mysql.SSUnknownSQLState, "extracting col %v default value failed", index)
Expand All @@ -954,7 +954,7 @@ func (conn *BackendConnection) readColumnDefinition(field *Field, index int) err
return err2.NewSQLError(mysql.CRMalformedPacket, mysql.SSUnknownSQLState, "extracting col %v default value failed", index)
}

//default value string[$len]
// default value string[$len]
field.defaultValue = colDef[pos:(pos + int(field.defaultValueLength))]
}
return nil
Expand Down Expand Up @@ -1139,12 +1139,10 @@ func (conn *BackendConnection) ReadQueryResult(maxrows int, wantfields bool) (re
return nil, false, 0, err2.NewSQLError(mysql.CRServerLost, mysql.SSUnknownSQLState, "%v", err)
}
if isEOFPacket(data) {

// This is what we expect.
// Warnings and status flags are ignored.
conn.c.recycleReadPacket()
// goto: read row loop

} else if isErrorPacket(data) {
defer conn.c.recycleReadPacket()
return nil, false, 0, ParseErrorPacket(data)
Expand Down
4 changes: 2 additions & 2 deletions pkg/mysql/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@ func (l *Listener) Listen() {
}

func (l *Listener) Close() {

}

func (l *Listener) handle(conn net.Conn, connectionID uint32) {
Expand Down Expand Up @@ -1255,7 +1254,8 @@ func (c *Conn) writePrepare(capabilities uint32, prepare *proto.Stmt) error {
name: "?",
fieldType: mysql.FieldTypeString,
flags: mysql.BinaryFlag,
charSet: 63}); err != nil {
charSet: 63,
}); err != nil {
return err
}
}
Expand Down
6 changes: 4 additions & 2 deletions pkg/mysql/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -361,8 +361,10 @@ func appendDateTime(buf []byte, t time.Time) ([]byte, error) {
// The current behavior depends on database/sql copying the result.
var zeroDateTime = []byte("0000-00-00 00:00:00.000000")

const digits01 = "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789"
const digits10 = "0000000000111111111122222222223333333333444444444455555555556666666666777777777788888888889999999999"
const (
digits01 = "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789"
digits10 = "0000000000111111111122222222223333333333444444444455555555556666666666777777777788888888889999999999"
)

func appendMicrosecs(dst, src []byte, decimals int) []byte {
if decimals <= 0 {
Expand Down
1 change: 0 additions & 1 deletion pkg/proto/rule/range.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,6 @@ func (s Stepper) compute(offset interface{}, n int) (interface{}, error) {
return &iterStr{length: 16, cnt: n}, nil
}
return nil, errors.Errorf("unsupported offset type: type=%T, unit=%s", offset, s.U)

}

func (s Stepper) iterTime(offset time.Time, cnt int, timeUnit time.Duration, reverse bool) Range {
Expand Down
2 changes: 0 additions & 2 deletions pkg/runtime/logical/logical.go
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,6 @@ func (c *composite) optimize() int {
sort.Sort(sortLogicals(c.ch))
removed := make(map[int]struct{})
switch c.op {

case Lor:
for i := 0; i < len(c.ch); i++ {
next, ok := c.ch[i].(*atom)
Expand Down Expand Up @@ -493,7 +492,6 @@ func EvalBool(l Logical) (bool, error) {
}, func(i interface{}) interface{} {
return !i.(bool)
})

if err != nil {
return false, err
}
Expand Down
6 changes: 4 additions & 2 deletions pkg/runtime/misc/other.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@ import (

const min = 0.000001

var _numReg = regexp.MustCompilePOSIX("^-?(0|[1-9][0-9]*)$")
var _floatReg = regexp.MustCompilePOSIX("^-?(0|[1-9][0-9]*)(.[0-9]+)?$")
var (
_numReg = regexp.MustCompilePOSIX("^-?(0|[1-9][0-9]*)$")
_floatReg = regexp.MustCompilePOSIX("^-?(0|[1-9][0-9]*)(.[0-9]+)?$")
)

func IsFloat64Equal(f1, f2 float64) bool {
if f1 > f2 {
Expand Down
1 change: 0 additions & 1 deletion pkg/runtime/rule/evaluator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,5 +130,4 @@ func TestEvaluator_Eval(t *testing.T) {
assert.NoError(t, err)
t.Logf("%s => %s", l.ToString("AND", "OR"), v)
})

}
6 changes: 4 additions & 2 deletions third_party/pools/resource_pool_flaky_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,10 @@ import (
"golang.org/x/net/context"
)

var lastID, count = atomic.NewInt64(0), atomic.NewInt64(0)
var waitStarts []time.Time
var (
lastID, count = atomic.NewInt64(0), atomic.NewInt64(0)
waitStarts []time.Time
)

type TestResource struct {
num int64
Expand Down
1 change: 0 additions & 1 deletion third_party/sync2/consolidator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,5 +99,4 @@ func TestConsolidator(t *testing.T) {
if !reflect.DeepEqual(con.Items(), want) {
t.Fatalf("expected consolidator to have two items %v", con.Items())
}

}

0 comments on commit 0ae562c

Please sign in to comment.