Hey,
the `-quotes denote a "raw string literal". Escape-sequences in raw string
literals are not interpreted - that's basically their purpose. So `t2`
contains the literal two-byte sequence `\n`. You can see that in the output
of `fmt.Println`, the newline is a 10, but t2 does not contain a 10, bu
Variable t2 has no newline in its value.
On Fri, Aug 21, 2020, 18:01 'Guilherme Dalmarco' via golang-nuts <
golang-nuts@googlegroups.com> wrote:
> Why *bytes.IndexByte *can not find '\n' in multiline string?
>
> package main
>
> import (
> "bytes"
> "fmt"
> )
>
> func main() {
> t1 := []byte("TES
Why *bytes.IndexByte *can not find '\n' in multiline string?
package main
import (
"bytes"
"fmt"
)
func main() {
t1 := []byte("TEST\n")
t2 := []byte(`TEST\n`)
t3 := byte('\n')
fmt.Println(t1)
fmt.Println(t2)
fmt.Println(t3)
fmt.Println(bytes.IndexByte(t1, t3))
fmt.Println(bytes.IndexByte(t2, t