Skip to content

Commit

Permalink
all: use fmt.Appendf
Browse files Browse the repository at this point in the history
Signed-off-by: cui fliter <[email protected]>
  • Loading branch information
cuishuang committed Oct 4, 2022
1 parent 6a9aaf1 commit 22b5116
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/cmd/go/internal/modfetch/coderepo.go
Original file line number Diff line number Diff line change
Expand Up @@ -962,7 +962,7 @@ func (r *codeRepo) GoMod(version string) (data []byte, err error) {
// for dependencies in the middle of a build, impossible to
// correct. So we stopped.
func LegacyGoMod(modPath string) []byte {
return []byte(fmt.Sprintf("module %s\n", modfile.AutoQuote(modPath)))
return fmt.Appendf(nil, "module %s\n", modfile.AutoQuote(modPath))
}

func (r *codeRepo) modPrefix(rev string) string {
Expand Down
4 changes: 2 additions & 2 deletions src/cmd/go/internal/modload/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -431,12 +431,12 @@ func ModInfoProg(info string, isgccgo bool) []byte {
// look at the module info in their init functions (see issue 29628),
// which won't work. See also issue 30344.
if isgccgo {
return []byte(fmt.Sprintf(`package main
return fmt.Appendf(nil, `package main
import _ "unsafe"
//go:linkname __set_debug_modinfo__ runtime.setmodinfo
func __set_debug_modinfo__(string)
func init() { __set_debug_modinfo__(%q) }
`, ModInfoData(info)))
`, ModInfoData(info))
}
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/trace/annotations.go
Original file line number Diff line number Diff line change
Expand Up @@ -1095,7 +1095,7 @@ Search log text: <form onsubmit="window.location.search+='&logtext='+window.logt
`))

func elapsed(d time.Duration) string {
b := []byte(fmt.Sprintf("%.9f", d.Seconds()))
b := fmt.Appendf(nil, "%.9f", d.Seconds())

// For subsecond durations, blank all zeros before decimal point,
// and all zeros between the decimal point and the first non-zero digit.
Expand Down
2 changes: 1 addition & 1 deletion src/net/smtp/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func (a *cramMD5Auth) Next(fromServer []byte, more bool) ([]byte, error) {
d := hmac.New(md5.New, []byte(a.secret))
d.Write(fromServer)
s := make([]byte, 0, d.Size())
return []byte(fmt.Sprintf("%s %x", a.username, d.Sum(s))), nil
return fmt.Appendf(nil, "%s %x", a.username, d.Sum(s)), nil
}
return nil, nil
}

0 comments on commit 22b5116

Please sign in to comment.