|
|
|
|
|
by lenish
2197 days ago
|
|
Not GP, but I've sometimes found libraries implementing similar concepts differently causing issues. E.g. libraryA.Result struct {
Err error
Data SomeDataType
}
libraryB.Result struct {
err string
Data SomeDataType
}
func (r libraryB.Result) Error() string {
return r.err
}
Now you have two different implementations of the same fundamental idea, but they each require different handling. In Go, where many things simply return an error type in addition to whatever value(s), you would now have three different approaches to error handling to deal with as opposed to just whatever the language specified as the best practice. |
|
Let your caller bring their own error type and instantiate your library code over that.