Browse Source

update Must2

Darien Raymond 7 năm trước cách đây
mục cha
commit
098244530b
1 tập tin đã thay đổi với 4 bổ sung5 xóa
  1. 4 5
      common/common.go

+ 4 - 5
common/common.go

@@ -11,9 +11,8 @@ func Must(err error) {
 	}
 }
 
-// Must2 panics if the second parameter is not nil.
-func Must2(v interface{}, err error) {
-	if err != nil {
-		panic(err)
-	}
+// Must2 panics if the second parameter is not nil, otherwise returns the first parameter.
+func Must2(v interface{}, err error) interface{} {
+	Must(err)
+	return v
 }