Skip to content

Commit

Permalink
*: fix gosimple check (pingcap#24460)
Browse files Browse the repository at this point in the history
  • Loading branch information
jianzhiyao authored May 10, 2021
1 parent 3b93528 commit b0dfa74
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 9 deletions.
4 changes: 2 additions & 2 deletions cmd/importcheck/importcheck.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func checkFile(path string) error {
continue
}
if !preIsStd {
return errors.New(fmt.Sprintf("stdlib %s need be group together and before non-stdlib group in %s", im.Path.Value, path))
return fmt.Errorf("stdlib %s need be group together and before non-stdlib group in %s", im.Path.Value, path)
}
continue
}
Expand All @@ -103,7 +103,7 @@ func checkFile(path string) error {
continue
}
if !checkSepWithNewline(src, importSpecs[i-1].Path.Pos(), im.Path.Pos()) {
return errors.New(fmt.Sprintf("non-stdlib %s need be group together and after stdlib group in %s", im.Path.Value, path))
return fmt.Errorf("non-stdlib %s need be group together and after stdlib group in %s", im.Path.Value, path)
}
preIsStd = false
}
Expand Down
4 changes: 2 additions & 2 deletions config/config_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,9 @@ func FlattenConfigItems(nestedConfig map[string]interface{}) map[string]interfac
}

func flatten(flatMap map[string]interface{}, nested interface{}, prefix string) {
switch nested.(type) {
switch nested := nested.(type) {
case map[string]interface{}:
for k, v := range nested.(map[string]interface{}) {
for k, v := range nested {
path := k
if prefix != "" {
path = prefix + "." + k
Expand Down
3 changes: 1 addition & 2 deletions store/tikv/mockstore/deadlock/deadlock_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
package deadlock

import (
"fmt"
"testing"

. "github.com/pingcap/check"
Expand All @@ -36,7 +35,7 @@ func (s *testDeadlockSuite) TestDeadlock(c *C) {
c.Assert(err, IsNil)
err = detector.Detect(3, 1, 300)
c.Assert(err, NotNil)
c.Assert(err.Error(), Equals, fmt.Sprintf("deadlock(200)"))
c.Assert(err.Error(), Equals, "deadlock(200)")
detector.CleanUp(2)
list2 := detector.waitForMap[2]
c.Assert(list2, IsNil)
Expand Down
2 changes: 0 additions & 2 deletions types/json/binary_functions.go
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,6 @@ func (bm *binaryModifier) doInsert(path PathExpression, newBj BinaryJSON) {
elems = append(elems, newBj)
}
bm.modifyValue, bm.err = buildBinaryObject(keys, elems)
return
}

func (bm *binaryModifier) remove(path PathExpression) BinaryJSON {
Expand Down Expand Up @@ -582,7 +581,6 @@ func (bm *binaryModifier) doRemove(path PathExpression) {
}
}
bm.modifyValue, bm.err = buildBinaryObject(keys, elems)
return
}

// rebuild merges the old and the modified JSON into a new BinaryJSON
Expand Down
2 changes: 1 addition & 1 deletion util/timeutil/time.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func InferSystemTZ() string {
case !ok:
path, err1 := filepath.EvalSymlinks("/etc/localtime")
if err1 == nil {
if strings.Index(path, "posixrules") != -1 {
if strings.Contains(path, "posixrules") {
path, err1 = inferOneStepLinkForPath("/etc/localtime")
if err1 != nil {
logutil.BgLogger().Error("locate timezone files failed", zap.Error(err1))
Expand Down

0 comments on commit b0dfa74

Please sign in to comment.