Last active
August 10, 2018 04:09
-
-
Save icholy/fc41b8cfe74506cf93ec6b0fba1fc4ce to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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