Hacker News new | ask | show | jobs
by tomjen3 2197 days ago
Can you articulate why? it seems to me that 'feel' should not be part of the discussion.
2 comments

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.
This is what interfaces are for.

Let your caller bring their own error type and instantiate your library code over that.

Not GP but:

It may frustrate coworkers who need to edit the code.

It adds another dependency into your workflow.