all: use fmt.Appendf

Signed-off-by: cui fliter <imcusg@gmail.com>
This commit is contained in:
cui fliter 2022-10-04 23:50:58 +08:00
parent 6a9aaf1f02
commit 22b51167b0
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
}