Hacker News new | past | comments | ask | show | jobs | submit login

People could be shoving square pegs into coincidentally square holes but having coded in Go for years I haven't seen this scenario in practice ever. It would take a lack of understanding of the objects you're working with combined with a pretty big gap in your tests to cause a problem and at that point it's still not the most likely bug you'll see



I agree with you, but I can think of one counter example from Go. “crypto/rand.Rand” and “math/rand.Rand” both satisfy “io.Reader” which has lead to people inadvertently using the less secure choice.

That said, I think it is less about implicit interfaces and more about confusion between similar namespaces. After all “bytes.Buffer” also satisfies “io.Reader”, and I don’t see people confusing it with “crypto/rand.Rand”.


How does go handle marking up types with interfaces and then using types without that explicit interface?

Do devs use the explicit interfaces at all? Do they treat implicitly casted types with more scrutiny? Does the tooling care?




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: