by webtopaz · 11y ago · 0 comments
But then what would the following "if" look like ?
This check is not really needed as the code would fail when a function which accepts scan.Writer would fail (compilation) if ColumnWriter is sent and if it doesn't satisfy the interface. However, this is easier to debug.
Other languages provide constructs to check for interface compliance, Go requires writing dummy code.
This is a debugging trick because Go interfaces use structural subtyping instead of explicitly declaring which types implement an interface. This is a calculated design decision with several trade offs. There is nothing "sad" about it.