Semantics of ReadDirFile.ReadDir

88 views
Skip to first unread message

Piotr Wieczorek

unread,
Feb 18, 2021, 7:02:39 PM2/18/21
to golang-nuts
Hi,
I'm writing a type implementing ReadDirFile interface, and I have some doubts how I should implement ReadDir method.
The comment says on one hand: "Subsequent calls on the same file will yield further DirEntry values." and on the other "If n <= 0, ReadDir returns all the DirEntry values from the directory // in a single slice.".
So what should be returned if user first calls dir.ReadDir(1) and next dir.ReadDir(0)?
Should the second call return all the DirEntry values or only the further ones?

Best,
Piotr

Ian Lance Taylor

unread,
Feb 18, 2021, 9:21:54 PM2/18/21
to Piotr Wieczorek, golang-nuts
It should only return the remaining ones.

Ian

Piotr Wieczorek

unread,
Feb 19, 2021, 3:04:17 AM2/19/21
to golang-nuts
Thanks!
Reply all
Reply to author
Forward
0 new messages