1
0
mirror of https://github.com/golang/go synced 2024-11-17 08:04:46 -07:00

all: use fmt.Appendf

Change-Id: I45f941ba3db26a12b3f56d93bdcd7f9e1d490346
GitHub-Last-Rev: 22b51167b0
GitHub-Pull-Request: golang/go#56030
Reviewed-on: https://go-review.googlesource.com/c/go/+/438539
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
This commit is contained in:
cui fliter 2022-10-04 15:59:56 +00:00 committed by Gopher Robot
parent 3380ee2520
commit 58158e990f
4 changed files with 5 additions and 5 deletions

View File

@ -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 {

View File

@ -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
}

View File

@ -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.

View File

@ -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
}