Skip to content

Commit d41f1fa

Browse files
committed
all: replace fmt.Sprintf("%d") with strconv.Itoa
Than fmt.Sprintf("%d",
1 parent 20e9b7f commit d41f1fa

File tree

8 files changed

+20
-12
lines changed

8 files changed

+20
-12
lines changed

src/cmd/covdata/argsmerge.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@
44

55
package main
66

7-
import "fmt"
7+
import (
8+
"fmt"
9+
"strconv"
10+
)
811

912
type argvalues struct {
1013
osargs []string
@@ -49,7 +52,7 @@ func (a *argstate) Merge(state argvalues) {
4952
func (a *argstate) ArgsSummary() map[string]string {
5053
m := make(map[string]string)
5154
if len(a.state.osargs) != 0 {
52-
m["argc"] = fmt.Sprintf("%d", len(a.state.osargs))
55+
m["argc"] = strconv.Itoa(len(a.state.osargs))
5356
for k, a := range a.state.osargs {
5457
m[fmt.Sprintf("argv%d", k)] = a
5558
}

src/cmd/go/internal/modfetch/codehost/svn.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"os"
1313
"path"
1414
"path/filepath"
15+
"strconv"
1516
"time"
1617
)
1718

@@ -32,7 +33,7 @@ func svnParseStat(rev, out string) (*RevInfo, error) {
3233
}
3334

3435
info := &RevInfo{
35-
Name: fmt.Sprintf("%d", log.Logentry.Revision),
36+
Name: strconv.FormatInt(log.Logentry.Revision, 10),
3637
Short: fmt.Sprintf("%012d", log.Logentry.Revision),
3738
Time: t.UTC(),
3839
Version: rev,

src/cmd/go/internal/modfetch/codehost/vcs.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,7 @@ func (d *deleteCloser) Close() error {
488488
}
489489

490490
func hgParseStat(rev, out string) (*RevInfo, error) {
491-
f := strings.Fields(string(out))
491+
f := strings.Fields(out)
492492
if len(f) < 3 {
493493
return nil, vcsErrorf("unexpected response from hg log: %q", out)
494494
}
@@ -567,7 +567,7 @@ func bzrParseStat(rev, out string) (*RevInfo, error) {
567567
}
568568

569569
info := &RevInfo{
570-
Name: fmt.Sprintf("%d", revno),
570+
Name: strconv.FormatInt(revno, 10),
571571
Short: fmt.Sprintf("%012d", revno),
572572
Time: tm,
573573
Version: rev,

src/cmd/internal/src/pos.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"bytes"
1111
"fmt"
1212
"io"
13+
"strconv"
1314
)
1415

1516
// A Pos encodes a source position consisting of a (line, column) number pair
@@ -455,12 +456,12 @@ func (x lico) withStmt(stmt uint) lico {
455456
}
456457

457458
func (x lico) lineNumber() string {
458-
return fmt.Sprintf("%d", x.Line())
459+
return strconv.FormatUint(uint64(x.Line()), 10)
459460
}
460461

461462
func (x lico) lineNumberHTML() string {
462463
if x.IsStmt() == PosDefaultStmt {
463-
return fmt.Sprintf("%d", x.Line())
464+
return strconv.FormatUint(uint64(x.Line()), 10)
464465
}
465466
style, pfx := "b", "+"
466467
if x.IsStmt() == PosNotStmt {

src/go/token/position.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ package token
77
import (
88
"fmt"
99
"sort"
10+
"strconv"
1011
"sync"
1112
"sync/atomic"
1213
)
@@ -41,7 +42,7 @@ func (pos Position) String() string {
4142
if s != "" {
4243
s += ":"
4344
}
44-
s += fmt.Sprintf("%d", pos.Line)
45+
s += strconv.Itoa(pos.Line)
4546
if pos.Column != 0 {
4647
s += fmt.Sprintf(":%d", pos.Column)
4748
}

src/internal/buildcfg/cfg.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616
"os"
1717
"path/filepath"
1818
"runtime"
19+
"strconv"
1920
"strings"
2021
)
2122

@@ -181,7 +182,7 @@ func GOGOARCH() (name, value string) {
181182
case "amd64":
182183
return "GOAMD64", fmt.Sprintf("v%d", GOAMD64)
183184
case "arm":
184-
return "GOARM", fmt.Sprintf("%d", GOARM)
185+
return "GOARM", strconv.Itoa(GOARM)
185186
case "mips", "mipsle":
186187
return "GOMIPS", GOMIPS
187188
case "mips64", "mips64le":

src/net/http/triv.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ type Counter struct {
3939
func (ctr *Counter) String() string {
4040
ctr.mu.Lock()
4141
defer ctr.mu.Unlock()
42-
return fmt.Sprintf("%d", ctr.n)
42+
return strconv.Itoa(ctr.n)
4343
}
4444

4545
func (ctr *Counter) ServeHTTP(w http.ResponseWriter, req *http.Request) {

src/runtime/coverage/emit.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616
"path/filepath"
1717
"reflect"
1818
"runtime"
19+
"strconv"
1920
"sync/atomic"
2021
"time"
2122
"unsafe"
@@ -357,7 +358,7 @@ func (s *emitState) openMetaFile(metaHash [16]byte, metaLen uint64) error {
357358
fi, err := os.Stat(s.mfname)
358359
if err != nil || fi.Size() != int64(metaLen) {
359360
// We need a new meta-file.
360-
tname := "tmp." + fn + fmt.Sprintf("%d", time.Now().UnixNano())
361+
tname := "tmp." + fn + strconv.FormatInt(time.Now().UnixNano(), 10)
361362
s.mftmp = filepath.Join(s.outdir, tname)
362363
s.mf, err = os.Create(s.mftmp)
363364
if err != nil {
@@ -613,7 +614,7 @@ func (s *emitState) VisitFuncs(f encodecounter.CounterVisitorFn) error {
613614
// is also used to capture GOOS + GOARCH values as well.
614615
func captureOsArgs() map[string]string {
615616
m := make(map[string]string)
616-
m["argc"] = fmt.Sprintf("%d", len(os.Args))
617+
m["argc"] = strconv.Itoa(len(os.Args))
617618
for k, a := range os.Args {
618619
m[fmt.Sprintf("argv%d", k)] = a
619620
}

0 commit comments

Comments
 (0)