Running this program:
package main
import (
"bytes"
"fmt"
"io"
)
func main() {
r, w := io.Pipe()
go func() {
defer w.Close()
in := 'a' // single quote
fmt.Println("writing: ", in)
fmt.Fprint(w, in)
}()
defer r.Close()
buf := new(bytes.Buffer)
buf.ReadFrom(r)
fmt.Print("read: ", buf.Bytes())
}
This outputs:
writing: 97
read: [57 55]
When I do in := "a"
or fmt.Fprint(w, string(r))
, it works as expected (read: [97]
).
Is 97 equal to [57, 55] somehow?