Check first for runtime defined array (typ.cat of valueT) to avoid checking inexisting properties (an panic), when deciding to use appendSlice or not. Fixes #880.
24 lines
331 B
Go
24 lines
331 B
Go
package main
|
|
|
|
import (
|
|
"bufio"
|
|
"bytes"
|
|
)
|
|
|
|
func main() {
|
|
var buf1 = make([]byte, 1024)
|
|
var buf2 []byte
|
|
buf1 = []byte("Hallo\nTest\nLine3")
|
|
|
|
s := bufio.NewScanner(bytes.NewReader(buf1))
|
|
for s.Scan() {
|
|
buf2 = append(buf2, append(s.Bytes(), []byte("\n")...)...)
|
|
}
|
|
print(string(buf2))
|
|
}
|
|
|
|
// Output:
|
|
// Hallo
|
|
// Test
|
|
// Line3
|