io/fs.File not embedding io.ReadCloser?

75 views
Skip to first unread message

diegoaugu...@gmail.com

unread,
Dec 21, 2020, 10:13:59 AM12/21/20
to golang-nuts
Hi,
I was reading https://tip.golang.org/pkg/io/fs/#File and noticed that interface File is not embedding io.ReadCloser. Even though the signature of the methods are identical, It would probably be a good idea to embed io.ReadCloser (or both io.Reader and io.Closer) to state the intention of making them compatible (and also have the excellent documentation on how to implement those methods).
So my actual question could be rephrased: is io/fs.File's Read and Close methods intended to be used in the exact same way as io.ReadCloser? If so, is there a reason why it is re-defining those two methods on its own? If not, wouldn't it be better to have different method names to avoid any confusion?

Thank you!

Axel Wagner

unread,
Dec 21, 2020, 10:21:36 AM12/21/20
to diegoaugu...@gmail.com, golang-nuts
This has been discussed in the proposal issue:
https://github.com/golang/go/issues/41190#issuecomment-722342397
I'm not sure this will give you a satisfactory answer, but at least it proves the team is aware :)

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/5d7238d9-ce52-4c5d-95b2-c0d0a5346a7bn%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages