Skip to content
  • Abhinav Gupta's avatar
    errors: Update for errors.Is/As (#134) · 701df769
    Abhinav Gupta authored
    This PR updates the guidance we have for errors to reflect best practices since
    Go 1.13's error APIs. The high-level overview of the guidance is:
    
    - use `errors.New` for static strings,
      exporting a `var` if it needs to be matched
    - declare a custom error type if it needs to be matched
    - use `fmt.Errorf` for dynamic strings if it does not need to be matched
    - use `fmt.Errorf` with `%w` when wrapping if the wrapped error needs to be
      matched
    - name top-level error variables `errFoo` or `ErrFoo`
    - name error types `FooError`
    
    Resolves #132 #8 
    Ref GO-1014
    701df769