4 ms·
You can state in documentation what interfaces a type implements. It is not uncommon to do that. For instance, the os package could have written something like:
by dsymonds 13y ago
You can state in documentation what interfaces a type implements. It is not uncommon to do that. For instance, the os package could have written something like:
// File represents an open file.
// It implements the io.Reader, io.Writer and io.Closer interfaces.
type File struct {
...
}
- DanWaterworth 13y agoRelying on people to do things consistently is not a good strategy. I'm sitting in front of a machine that I'd like to do that for me. Having to document this information manually is a disadvantage of Go when compared to other languages.
- MetaCosm 13y agoIf I make a new interface that is an mix of io.Reader, io.Writer and io.Closer and I call this interface YouDidNotSeeMeComing -- then the file struct would also implement it... without even knowing it!