Hacker News new | ask | show | jobs
by hjr265 4396 days ago
I would definitely prefer jmpeax's answer.

Although, there was a question/discussion similar to this here: https://www.youtube.com/watch?v=u-kkf76TDHE#t=2584

The gist was that, if the interface and the structs that are supposed to satisfy that interface belong to the same package, and then you want to prevent any outsider from implementing that interface, you can actually include an unexported method:

    type HtmlStringer interface {
        ToString() string
        isHtmlStringer()
    }
Since it is unexported, no outsider struct can actually satisfy this interface anymore.