I'm not sure what you're asking. I was pointing out that if you need to enforce a return result that will have either a value or an error, you can simple write a struct/interface that does that.
Like, you can create an interface that's read only for the return result like:
interface ReadableResult {
HasResult() bool
Result() whatever
Error() error
}
Then to create the result you have a writable interface for setting values, and enforce the 'only one of the two' semantics from the setters:
interface WritableResult {
SetResult(whatever)
SetError(error)
}
Struct MyResult{
err error
result whatever
}
.... Implementation here.
It's extra code, but it should be a rare necessity, at least in my experience. Res, err := getResult() always worked fine for me.