]> Cypherpunks.ru repositories - gostls13.git/commitdiff
all: replace fmt.Sprintf("%d") with strconv.Itoa
authorPhilippe Antoine <contact@catenacyber.fr>
Thu, 23 Mar 2023 08:14:39 +0000 (08:14 +0000)
committerGopher Robot <gobot@golang.org>
Fri, 31 Mar 2023 18:41:24 +0000 (18:41 +0000)
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>
src/cmd/covdata/argsmerge.go
src/cmd/go/internal/modfetch/codehost/svn.go
src/cmd/go/internal/modfetch/codehost/vcs.go
src/go/token/position.go
src/internal/buildcfg/cfg.go
src/net/http/triv.go
src/runtime/coverage/emit.go

index 8815a4a838e9ed84ef7c8351d4fc719e83661b2e..f591e3abd4049c8bae97b54863ca9c5d61fc7609 100644 (file)
@@ -4,7 +4,10 @@
 
 package main
 
-import "fmt"
+import (
+       "fmt"
+       "strconv"
+)
 
 type argvalues struct {
        osargs []string
@@ -49,7 +52,7 @@ func (a *argstate) Merge(state argvalues) {
 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
                }
index 6ec9e59c9c6469533f42d533eb5cbd9ae3afa6f6..bcb4126304d824e334639984f9a3b136a87ba3ec 100644 (file)
@@ -12,6 +12,7 @@ import (
        "os"
        "path"
        "path/filepath"
+       "strconv"
        "time"
 )
 
@@ -32,7 +33,7 @@ func svnParseStat(rev, out string) (*RevInfo, error) {
        }
 
        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,
index afca04e96a08bb6b04065d80dced10f92f9275ed..0a1124b1a907c32392c94161620480a57bbf414f 100644 (file)
@@ -488,7 +488,7 @@ func (d *deleteCloser) Close() error {
 }
 
 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)
        }
@@ -567,7 +567,7 @@ func bzrParseStat(rev, out string) (*RevInfo, error) {
        }
 
        info := &RevInfo{
-               Name:    fmt.Sprintf("%d", revno),
+               Name:    strconv.FormatInt(revno, 10),
                Short:   fmt.Sprintf("%012d", revno),
                Time:    tm,
                Version: rev,
index c9dba9e79a3c400684d49b477b32f57c5c964a12..a6443828860e59b9766a4182360145dc97903f94 100644 (file)
@@ -7,6 +7,7 @@ package token
 import (
        "fmt"
        "sort"
+       "strconv"
        "sync"
        "sync/atomic"
 )
@@ -41,7 +42,7 @@ func (pos Position) String() string {
                if s != "" {
                        s += ":"
                }
-               s += fmt.Sprintf("%d", pos.Line)
+               s += strconv.Itoa(pos.Line)
                if pos.Column != 0 {
                        s += fmt.Sprintf(":%d", pos.Column)
                }
index a0736aaf742cdd25c497e0b92b42133e17e7fa86..b97b9c1b53a91e221bcbb42ef6007876f845bb6e 100644 (file)
@@ -16,6 +16,7 @@ import (
        "os"
        "path/filepath"
        "runtime"
+       "strconv"
        "strings"
 )
 
@@ -181,7 +182,7 @@ func GOGOARCH() (name, value string) {
        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":
index 32edbbb3440edbcff4d84c44c822304183613c0a..f614922c242a1603688a1a6d935eb3a340fa8cf0 100644 (file)
@@ -39,7 +39,7 @@ type Counter struct {
 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) {
index 300ff2caca7d1e969cf79efc2c7f93dab030d02d..0f77ce287b0a81dba33225e4b71c666a6d3f5684 100644 (file)
@@ -16,6 +16,7 @@ import (
        "path/filepath"
        "reflect"
        "runtime"
+       "strconv"
        "sync/atomic"
        "time"
        "unsafe"
@@ -357,7 +358,7 @@ func (s *emitState) openMetaFile(metaHash [16]byte, metaLen uint64) error {
        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 {
@@ -613,7 +614,7 @@ func (s *emitState) VisitFuncs(f encodecounter.CounterVisitorFn) error {
 // 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
        }