google / uuid

Go package for UUIDs based on RFC 4122 and DCE 1.1: Authentication and Security Services.
BSD 3-Clause "New" or "Revised" License
5.26k stars 362 forks source link

MarshalBinary() error return value redundant #42

Closed MrWaggel closed 5 years ago

MrWaggel commented 5 years ago

err is always nil, is there any reason behind it? I know it probably won't be fixed to avoid breaking changes. But doesn't this cause unneeded overhead, or is the compiler smart enough to ignore this?

// MarshalBinary implements encoding.BinaryMarshaler.
func (uuid UUID) MarshalBinary() ([]byte, error) {
    return uuid[:], nil
}

https://github.com/google/uuid/blob/9b3b1e0f5f99ae461456d768e7d301a7acdaa2d8/marshal.go#L27

pborman commented 5 years ago

This is satisfying the encoding.BinaryMarshaler interface so it must return the nil.