I was looking at NewScanner in the official go docs and it mentions the parameter to be passed to bufio.NewScanner
should be of type io.Reader
. However, the following works for me:
file, err := os.Open("filename")
scanner := bufio.NewScanner(file)
The same can be seen for os.Stdin
as well. Given this what is the difference between os.File
, os.Stdin
and io.Reader
? Are they interchangeable?