common.go 527 B

1234567891011121314151617181920212223
  1. // Package common contains common utilities that are shared among other packages.
  2. // See each sub-package for detail.
  3. package common
  4. //go:generate errorgen
  5. // Must panics if err is not nil.
  6. func Must(err error) {
  7. if err != nil {
  8. panic(err)
  9. }
  10. }
  11. // Must2 panics if the second parameter is not nil, otherwise returns the first parameter.
  12. func Must2(v interface{}, err error) interface{} {
  13. Must(err)
  14. return v
  15. }
  16. // Error2 returns the err from the 2nd parameter.
  17. func Error2(v interface{}, err error) error {
  18. return err
  19. }