The "Effective Go" states:
By convention, one-method interfaces are named by the method name plus an -er suffix or similar modification to construct an agent noun:
Reader
,Writer
,Formatter
,CloseNotifier
etc.
bufio.io
package contains this:
// Reader implements buffering for an io.Reader object.
type Reader struct {
buf []byte
rd io.Reader
r, w int
err error
lastByte int
lastRuneSize int
}
Is it idiomatic having structs named like "*er"? Especially in this case it's a struct
with the same name as io.Reader
which is an interface.
If it's not in Effective Go or the specs then it's a matter of opinion really, I'd say it's fine as long as it makes sense.
Using bufio.Reader
or bytes.Reader
as an example, they make perfect sense to be named that way.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With