News for hackers. Stuff that matters.
Re:Too Much Go Misdirection by throwaway894345 on Monday May 19, 2025 @05:30PM (#44035100)
You don’t need to downcast to interface, io.Reader is already an interface, and a type assertion on an interface (“if this io.Reader is just a byteslice and cursor, then use the byteslice”) is strictly safer than an untagged union and equally safe with a tagged union.

I wish Go had Rust-like enums as well, but they don’t make anything safer in this case (except for the nil interface concern which isn’t the point you’re raising).

There are no comments on this comment yet.