Re: [go-nuts] [string] multiline stirng and break line "\n"

2020-08-21 Thread 'Axel Wagner' via golang-nuts
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,

Re: [go-nuts] [string] multiline stirng and break line "\n"

2020-08-21 Thread Jan Mercl
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 :=

[go-nuts] [string] multiline stirng and break line "\n"

2020-08-21 Thread 'Guilherme Dalmarco' via golang-nuts
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,