Skip to content

Commit

Permalink
*: fix staticcheck errors in folder types (pingcap#13773)
Browse files Browse the repository at this point in the history
  • Loading branch information
hsqlu authored and sre-bot committed Dec 4, 2019
1 parent 6dabaad commit 018d3c3
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 93 deletions.
17 changes: 0 additions & 17 deletions types/datum.go
Original file line number Diff line number Diff line change
Expand Up @@ -1659,23 +1659,6 @@ func invalidConv(d *Datum, tp byte) (Datum, error) {
return Datum{}, errors.Errorf("cannot convert datum from %s to type %s.", KindStr(d.Kind()), TypeStr(tp))
}

func (d *Datum) convergeType(hasUint, hasDecimal, hasFloat *bool) (x Datum) {
x = *d
switch d.Kind() {
case KindUint64:
*hasUint = true
case KindFloat32:
f := d.GetFloat32()
x.SetFloat64(float64(f))
*hasFloat = true
case KindFloat64:
*hasFloat = true
case KindMysqlDecimal:
*hasDecimal = true
}
return x
}

// NewDatum creates a new Datum from an interface{}.
func NewDatum(in interface{}) (d Datum) {
switch x := in.(type) {
Expand Down
17 changes: 0 additions & 17 deletions types/json/binary.go
Original file line number Diff line number Diff line change
Expand Up @@ -357,23 +357,6 @@ func marshalStringTo(buf, s []byte) []byte {
return buf
}

func (bj BinaryJSON) marshalValueEntryTo(buf []byte, entryOff int) ([]byte, error) {
tpCode := bj.Value[entryOff]
switch tpCode {
case TypeCodeLiteral:
buf = marshalLiteralTo(buf, bj.Value[entryOff+1])
default:
offset := endian.Uint32(bj.Value[entryOff+1:])
tmp := BinaryJSON{TypeCode: tpCode, Value: bj.Value[offset:]}
var err error
buf, err = tmp.marshalTo(buf)
if err != nil {
return nil, errors.Trace(err)
}
}
return buf, nil
}

func marshalLiteralTo(b []byte, litType byte) []byte {
switch litType {
case LiteralFalse:
Expand Down
39 changes: 0 additions & 39 deletions types/time.go
Original file line number Diff line number Diff line change
Expand Up @@ -2252,16 +2252,6 @@ func skipWhiteSpace(input string) string {
return ""
}

var weekdayAbbrev = map[string]gotime.Weekday{
"Sun": gotime.Sunday,
"Mon": gotime.Monday,
"Tue": gotime.Tuesday,
"Wed": gotime.Wednesday,
"Thu": gotime.Tuesday,
"Fri": gotime.Friday,
"Sat": gotime.Saturday,
}

var monthAbbrev = map[string]gotime.Month{
"Jan": gotime.January,
"Feb": gotime.February,
Expand Down Expand Up @@ -2628,35 +2618,6 @@ func monthNumeric(t *MysqlTime, input string, ctx map[string]int) (string, bool)
return input[length:], true
}

func parseOrdinalNumbers(input string) (value int, remain string) {
for i, c := range input {
if !unicode.IsDigit(c) {
v, err := strconv.ParseUint(input[:i], 10, 64)
if err != nil {
return -1, input
}
value = int(v)
break
}
}
switch {
case strings.HasPrefix(remain, "st"):
if value == 1 {
remain = remain[2:]
return
}
case strings.HasPrefix(remain, "nd"):
if value == 2 {
remain = remain[2:]
return
}
case strings.HasPrefix(remain, "th"):
remain = remain[2:]
return
}
return -1, input
}

// DateFSP gets fsp from date string.
func DateFSP(date string) (fsp int) {
i := strings.LastIndex(date, ".")
Expand Down
20 changes: 0 additions & 20 deletions types/time_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -439,26 +439,6 @@ func (s *testTimeSuite) TestYear(c *C) {
}
}

func (s *testTimeSuite) getLocation(c *C) *time.Location {
locations := []string{"Asia/Shanghai", "Europe/Berlin"}
timeFormat := "Jan 2, 2006 at 3:04pm (MST)"

z, err := time.LoadLocation(locations[0])
c.Assert(err, IsNil)

t1, err := time.ParseInLocation(timeFormat, "Jul 9, 2012 at 5:02am (CEST)", z)
c.Assert(err, IsNil)
t2, err := time.Parse(timeFormat, "Jul 9, 2012 at 5:02am (CEST)")
c.Assert(err, IsNil)

if t1.Equal(t2) {
z, err = time.LoadLocation(locations[1])
c.Assert(err, IsNil)
}

return z
}

func (s *testTimeSuite) TestCodec(c *C) {
defer testleak.AfterTest(c)()

Expand Down

0 comments on commit 018d3c3

Please sign in to comment.