Skip to content

Instantly share code, notes, and snippets.

@achille-roussel
Created August 12, 2016 19:23
Show Gist options
  • Save achille-roussel/b83872776e84ad8f957b017e1f0ff4a8 to your computer and use it in GitHub Desktop.
Save achille-roussel/b83872776e84ad8f957b017e1f0ff4a8 to your computer and use it in GitHub Desktop.
Go Inline Interfaces
func errorTypeOf(err error) errorType {
if err == nil {
return errorNone
}
switch e := err.(type) {
case interface {
Timeout() bool
}:
if e.Timeout() {
return errorTimeout
}
case interface {
Temporary() bool
}:
if e.Temporary() {
return errorTemporary
}
}
return errorFatal
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment