github.com/wangyougui/gf/v2@v2.6.5/util/gutil/gutil_is.go (about)

     1  // Copyright GoFrame Author(https://goframe.org). All Rights Reserved.
     2  //
     3  // This Source Code Form is subject to the terms of the MIT License.
     4  // If a copy of the MIT was not distributed with this file,
     5  // You can obtain one at https://github.com/wangyougui/gf.
     6  
     7  package gutil
     8  
     9  import (
    10  	"reflect"
    11  
    12  	"github.com/wangyougui/gf/v2/internal/empty"
    13  )
    14  
    15  // IsEmpty checks given `value` empty or not.
    16  // It returns false if `value` is: integer(0), bool(false), slice/map(len=0), nil;
    17  // or else returns true.
    18  func IsEmpty(value interface{}) bool {
    19  	return empty.IsEmpty(value)
    20  }
    21  
    22  // IsTypeOf checks and returns whether the type of `value` and `valueInExpectType` equal.
    23  func IsTypeOf(value, valueInExpectType interface{}) bool {
    24  	return reflect.TypeOf(value) == reflect.TypeOf(valueInExpectType)
    25  }