mirror of
https://github.com/shtorm-7/sing-box-extended.git
synced 2026-06-25 20:03:12 +03:00
Update XHTTP
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
package common
|
||||
|
||||
import "reflect"
|
||||
|
||||
// Must panics if err is not nil.
|
||||
func Must(err error) {
|
||||
if err != nil {
|
||||
@@ -17,3 +19,14 @@ func Must2(v interface{}, err error) interface{} {
|
||||
func Error2(v interface{}, err error) error {
|
||||
return err
|
||||
}
|
||||
|
||||
// CloseIfExists call obj.Close() if obj is not nil.
|
||||
func CloseIfExists(obj any) error {
|
||||
if obj != nil {
|
||||
v := reflect.ValueOf(obj)
|
||||
if !v.IsNil() {
|
||||
return Close(obj)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user