Skip to content

Instantly share code, notes, and snippets.

@icholy
Last active August 10, 2018 04:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save icholy/fc41b8cfe74506cf93ec6b0fba1fc4ce to your computer and use it in GitHub Desktop.
Save icholy/fc41b8cfe74506cf93ec6b0fba1fc4ce to your computer and use it in GitHub Desktop.
type Checker struct {
err error
}
func (c *Checker) Check(cond bool, err error) {
if !cond && c.err == nil {
c.err = err
}
}
func (c *Checker) Checkf(cond bool, format string, args ...string) {
c.Check(cond, fmt.Errorf(format, args...))
}
func (c Checker) Err() error {
return c.err
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment