common.go 497 B

123456789101112131415161718
  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 go run $GOPATH/src/v2ray.com/core/common/errors/errorgen/main.go -pkg common -path Common
  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. }