This was found by running `git grep 'fmt.Sprintf("%d",' | grep -v test | grep -v vendor`
And this was automatically fixed with gotiti https://github.com/catenacyber/gotiti
and using unconvert https://github.com/mdempsky/unconvert
to check if there was (tool which fixed another useless cast)
Change-Id: I023926bc4aa8d51de45f712ac739a0a80145c28c
GitHub-Last-Rev:
1063e32e5b69b6f9bb17673887b8c4ebe5be8fe4
GitHub-Pull-Request: golang/go#59144
Reviewed-on: https://go-review.googlesource.com/c/go/+/477675
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
package main
-import "fmt"
+import (
+ "fmt"
+ "strconv"
+)
type argvalues struct {
osargs []string
func (a *argstate) ArgsSummary() map[string]string {
m := make(map[string]string)
if len(a.state.osargs) != 0 {
- m["argc"] = fmt.Sprintf("%d", len(a.state.osargs))
+ m["argc"] = strconv.Itoa(len(a.state.osargs))
for k, a := range a.state.osargs {
m[fmt.Sprintf("argv%d", k)] = a
}
"os"
"path"
"path/filepath"
+ "strconv"
"time"
)
}
info := &RevInfo{
- Name: fmt.Sprintf("%d", log.Logentry.Revision),
+ Name: strconv.FormatInt(log.Logentry.Revision, 10),
Short: fmt.Sprintf("%012d", log.Logentry.Revision),
Time: t.UTC(),
Version: rev,
}
func hgParseStat(rev, out string) (*RevInfo, error) {
- f := strings.Fields(string(out))
+ f := strings.Fields(out)
if len(f) < 3 {
return nil, vcsErrorf("unexpected response from hg log: %q", out)
}
}
info := &RevInfo{
- Name: fmt.Sprintf("%d", revno),
+ Name: strconv.FormatInt(revno, 10),
Short: fmt.Sprintf("%012d", revno),
Time: tm,
Version: rev,
import (
"fmt"
"sort"
+ "strconv"
"sync"
"sync/atomic"
)
if s != "" {
s += ":"
}
- s += fmt.Sprintf("%d", pos.Line)
+ s += strconv.Itoa(pos.Line)
if pos.Column != 0 {
s += fmt.Sprintf(":%d", pos.Column)
}
"os"
"path/filepath"
"runtime"
+ "strconv"
"strings"
)
case "amd64":
return "GOAMD64", fmt.Sprintf("v%d", GOAMD64)
case "arm":
- return "GOARM", fmt.Sprintf("%d", GOARM)
+ return "GOARM", strconv.Itoa(GOARM)
case "mips", "mipsle":
return "GOMIPS", GOMIPS
case "mips64", "mips64le":
func (ctr *Counter) String() string {
ctr.mu.Lock()
defer ctr.mu.Unlock()
- return fmt.Sprintf("%d", ctr.n)
+ return strconv.Itoa(ctr.n)
}
func (ctr *Counter) ServeHTTP(w http.ResponseWriter, req *http.Request) {
"path/filepath"
"reflect"
"runtime"
+ "strconv"
"sync/atomic"
"time"
"unsafe"
fi, err := os.Stat(s.mfname)
if err != nil || fi.Size() != int64(metaLen) {
// We need a new meta-file.
- tname := "tmp." + fn + fmt.Sprintf("%d", time.Now().UnixNano())
+ tname := "tmp." + fn + strconv.FormatInt(time.Now().UnixNano(), 10)
s.mftmp = filepath.Join(s.outdir, tname)
s.mf, err = os.Create(s.mftmp)
if err != nil {
// is also used to capture GOOS + GOARCH values as well.
func captureOsArgs() map[string]string {
m := make(map[string]string)
- m["argc"] = fmt.Sprintf("%d", len(os.Args))
+ m["argc"] = strconv.Itoa(len(os.Args))
for k, a := range os.Args {
m[fmt.Sprintf("argv%d", k)] = a
}