News for hackers. Stuff that matters.
Re:Maybe adding generics to Go is about syntax after all by artursapek on Tuesday September 04, 2018 @12:59PM (#17910599)
> However quite a few Go developers now use interfaces with an unexported method specifically to stop users from misusing their types in a context they didn't intend. I guess it's come full circle.

What a horrible hack. Why bother with that? Either export your interface, your don't.

Re:Maybe adding generics to Go is about syntax after all by cyphar on Tuesday September 04, 2018 @01:05PM (#17910663)
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.
Re:Maybe adding generics to Go is about syntax after all by burntsushi on Tuesday September 04, 2018 @01:50PM (#17911160)
> 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.