You should read Dave's presentation again. Asserting for a type is the wrong way to do it, your library should instead provide a helper for the specific parsing you want to do.
So if you want to know if this error is temporary, you should have this, inside the net package:
func IsTemporary(err error) bool {
// specific parsing
}
Similarly, if you
really want an error code:
func ErrorCode(err error) int {
// a type assertion, which is fine because we're inside the net package
v, ok := err.(ErrorWithStatusCode)
if ok {
return v.ErrorCode
}
}
(Note that in the standard net/http package, the result of an http call is inside the result, never in the error that is returned, whatever the status of the http call is)
Basically your package should give all tools so that callers can take a decision without knowing about internals of the package. Knowing the exact error code is probably not what a caller wants; what they probably want to know is whether the error is temporary or fatal, if they can retry with a chance of success, if they can take counter-measures and if they can't alert the user.