Skip to content

all: replace fmt.Sprintf("%d") with strconv.Itoa #59144

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/cmd/covdata/argsmerge.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@

package main

import "fmt"
import (
"fmt"
"strconv"
)

type argvalues struct {
osargs []string
Expand Down Expand Up @@ -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
}
Expand Down
3 changes: 2 additions & 1 deletion src/cmd/go/internal/modfetch/codehost/svn.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"os"
"path"
"path/filepath"
"strconv"
"time"
)

Expand All @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions src/cmd/go/internal/modfetch/codehost/vcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down Expand Up @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion src/go/token/position.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ package token
import (
"fmt"
"sort"
"strconv"
"sync"
"sync/atomic"
)
Expand Down Expand Up @@ -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)
}
Expand Down
3 changes: 2 additions & 1 deletion src/internal/buildcfg/cfg.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"os"
"path/filepath"
"runtime"
"strconv"
"strings"
)

Expand Down Expand Up @@ -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":
Expand Down
2 changes: 1 addition & 1 deletion src/net/http/triv.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
5 changes: 3 additions & 2 deletions src/runtime/coverage/emit.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"path/filepath"
"reflect"
"runtime"
"strconv"
"sync/atomic"
"time"
"unsafe"
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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
}
Expand Down