]> Cypherpunks repositories - gostls13.git/commitdiff
all: append(bytes, str...) works out of the box
authorDaniel Martí <mvdan@mvdan.cc>
Mon, 22 Aug 2022 21:11:03 +0000 (22:11 +0100)
committerDaniel Martí <mvdan@mvdan.cc>
Tue, 23 Aug 2022 21:04:06 +0000 (21:04 +0000)
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>

src/cmd/go/internal/modindex/write.go
src/cmd/internal/quoted/quoted.go
src/syscall/exec_linux.go
src/time/format.go

index 7db1fb087052c7d353f6fa8aaf7e2b8936f5bdbb..df1467d9d18a63884ac9d02d134f7fe1ce9b576b 100644 (file)
@@ -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) {
index b3d3c400ec7234755d455b464069aebad6ff29da..a81227507353bf9d088d65ba1c42ade631586280 100644 (file)
@@ -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:
index 4ae7f33462e9ef62f2dd1bef7ed1e83bfdcc2671..d9e9e6df440d4aa20a33bff421674cacc45f517d 100644 (file)
@@ -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
 }
index 1887e6bce60607a177472d100ce0da2bd75abc50..c32861c6db6b166f254173a6df0700e4212841bc 100644 (file)
@@ -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, ')')