os.file.Read() documentation should reflect io.Reader documentation #49470
Labels
Documentation
FrozenDueToAge
NeedsFix
The path to resolution is known, but the work has not been done.
Milestone
Currently the documentation for os.file.Read() consists of the following which can be found in source:
This is of course mirrored by the pkg.go.dev documentation site:
os.file.Read() makes a call to file.read() and in turn file.pfd.Read(), which within source implements io.Reader:
The documentation for io.Reader is much more verbose than for os.file.Read():
Making it so that os.file.Read() has documentation that is actually not 100% accurate. os.file.Read() states that it reads up to b []bytes and returns n number of bytes read, however because it implements io.Reader, what it actually does is reads up to AND stores in b []bytes what is read, and then returns n number of bytes read.
This ambiguity had me go down a bit of a rabbit hole as you can tell but I'm glad I have the answer as to how a simple expression such as string(b[:n]) actually contains information.
The text was updated successfully, but these errors were encountered: