4 ms·
Well -- what if you have multiple implementations of an interface and you want users to be able to choose between them (or rather, you want them to be able to w
by cyphar 8y ago
Well -- what if you have multiple implementations of an interface and you want users to be able to choose between them (or rather, you want them to be able to write functions around your interfaces)? I don't really like it much either, but it's a completely valid usecase for unexported methods. In fact I'm pretty sure this was an example from the language developers for why you can have unexported interface methods in Go.
- burntsushi 8y ago> In fact I'm pretty sure this was an example from the language developers for why you can have unexported interface methods in Go. Indeed. It's used in the standard library for describing Go's AST if I recall correctly.