I am attempting to pass an *strings.Reader
from one function to another. The content of the reader is "Foo"
. This is the code that creates/passes the reader:
_, err = funcNum2(strings.NewReader("Foo"))
... and the code that reads from it...
buf := []byte{}
_, err := reader.Read(buf)
if err != nil {
fmt.Printf("Error reading from reader: %v\n", err)
}
When I run the debugger and look at the value of reader
in method2
, I find that reader
still contains "Foo"
. However, can you please help me understand why, when I try to read into buf
, buf
is empty?