Skip to content

Commit

Permalink
Fix non-constant format strings
Browse files Browse the repository at this point in the history
```
$ make GO=gotip build
gotip version
go version devel go1.24-4865aadc Fri Nov 22 05:22:24 2024 +0000 linux/amd64
gofmt (simplify)
vet
dump_region/main.go:59:14: non-constant format string in call to fmt.Printf
pkg/check/privilege.go:146:51: non-constant format string in call to github.com/pingcap/tidb-tools/pkg/check.NewError
pkg/check/table_structure.go:130:19: non-constant format string in call to github.com/pingcap/tidb-tools/pkg/check.NewError
pkg/check/table_structure.go:136:19: non-constant format string in call to github.com/pingcap/tidb-tools/pkg/check.NewError
importer/config.go:73:14: non-constant format string in call to fmt.Printf
make: *** [Makefile:86: check] Error 1
```

Related: golang/go#60529
  • Loading branch information
dveeden committed Nov 22, 2024
1 parent c85ad9c commit 742ad26
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion dump_region/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ type keyRange struct {
func main() {
flag.Parse()
if *printVersion {
fmt.Printf(utils.GetRawInfo("dump_region"))
fmt.Println(utils.GetRawInfo("dump_region"))
return
}

Expand Down
2 changes: 1 addition & 1 deletion importer/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func (c *Config) Parse(arguments []string) error {
}

if c.printVersion {
fmt.Printf(utils.GetRawInfo("importer"))
fmt.Println(utils.GetRawInfo("importer"))
return flag.ErrHelp
}

Expand Down
6 changes: 5 additions & 1 deletion pkg/check/privilege.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,11 @@ func verifyPrivileges(result *Result, grants []string, expectedGrants map[mysql.
// get username and hostname
node, err := parser.New().ParseOneStmt(grant, "", "")
if err != nil {
result.Errors = append(result.Errors, NewError(errors.Annotatef(err, "grant %s, grant after replace %s", grants[i], grant).Error()))
result.Errors = append(result.Errors,
NewError("%s",
errors.Annotatef(err, "grant %s, grant after replace %s", grants[i], grant).Error(),
),
)
return
}
grantStmt, ok := node.(*ast.GrantStmt)
Expand Down
4 changes: 2 additions & 2 deletions pkg/check/table_structure.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,13 @@ func (c *TablesChecker) Check(ctx context.Context) *Result {
if len(r.State) == 0 {
r.State = StateWarning
}
e := NewError(tableMsg + option.errMessage)
e := NewError("%s", tableMsg+option.errMessage)
e.Severity = StateWarning
e.Instruction = option.instruction
r.Errors = append(r.Errors, e)
case StateFailure:
r.State = StateFailure
e := NewError(tableMsg + option.errMessage)
e := NewError("%s", tableMsg+option.errMessage)
e.Instruction = option.instruction
r.Errors = append(r.Errors, e)
}
Expand Down

0 comments on commit 742ad26

Please sign in to comment.