mirror of
https://github.com/golang/go
synced 2024-11-17 11:14:46 -07:00
all: append(bytes, str...) works out of the box
From the append docs in the builtin package: As a special case, it is legal to append a string to a byte slice, like this: slice = append([]byte("hello "), "world"...) Change-Id: Ib14039a7476873b12a3aefccd8863e8d628b9249 Reviewed-on: https://go-review.googlesource.com/c/go/+/425102 Reviewed-by: hopehook <hopehook@qq.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: David Chase <drchase@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
This commit is contained in:
parent
44d057d581
commit
790d60537e
@ -126,7 +126,7 @@ func (e *encoder) String(s string) {
|
||||
e.strings[s] = pos
|
||||
e.Int(pos)
|
||||
e.stringTable = binary.AppendUvarint(e.stringTable, uint64(len(s)))
|
||||
e.stringTable = append(e.stringTable, []byte(s)...)
|
||||
e.stringTable = append(e.stringTable, s...)
|
||||
}
|
||||
|
||||
func (e *encoder) Bool(b bool) {
|
||||
|
@ -83,16 +83,16 @@ func Join(args []string) (string, error) {
|
||||
}
|
||||
switch {
|
||||
case !sawSpace && !sawSingleQuote && !sawDoubleQuote:
|
||||
buf = append(buf, []byte(arg)...)
|
||||
buf = append(buf, arg...)
|
||||
|
||||
case !sawSingleQuote:
|
||||
buf = append(buf, '\'')
|
||||
buf = append(buf, []byte(arg)...)
|
||||
buf = append(buf, arg...)
|
||||
buf = append(buf, '\'')
|
||||
|
||||
case !sawDoubleQuote:
|
||||
buf = append(buf, '"')
|
||||
buf = append(buf, []byte(arg)...)
|
||||
buf = append(buf, arg...)
|
||||
buf = append(buf, '"')
|
||||
|
||||
default:
|
||||
|
@ -590,7 +590,7 @@ func forkExecPipe(p []int) (err error) {
|
||||
func formatIDMappings(idMap []SysProcIDMap) []byte {
|
||||
var data []byte
|
||||
for _, im := range idMap {
|
||||
data = append(data, []byte(itoa.Itoa(im.ContainerID)+" "+itoa.Itoa(im.HostID)+" "+itoa.Itoa(im.Size)+"\n")...)
|
||||
data = append(data, itoa.Itoa(im.ContainerID)+" "+itoa.Itoa(im.HostID)+" "+itoa.Itoa(im.Size)+"\n"...)
|
||||
}
|
||||
return data
|
||||
}
|
||||
|
@ -588,7 +588,7 @@ func (t Time) GoString() string {
|
||||
// Of these, Location(loc.name) is the least disruptive. This is an edge
|
||||
// case we hope not to hit too often.
|
||||
buf = append(buf, `time.Location(`...)
|
||||
buf = append(buf, []byte(quote(loc.name))...)
|
||||
buf = append(buf, quote(loc.name)...)
|
||||
buf = append(buf, ')')
|
||||
}
|
||||
buf = append(buf, ')')
|
||||
|
Loading…
Reference in New Issue
Block a user