Files
gf/container/gvar/gvar_is.go

52 lines
1.2 KiB
Go
Raw Normal View History

2021-01-17 21:46:25 +08:00
// Copyright GoFrame Author(https://goframe.org). All Rights Reserved.
2020-12-14 18:54:14 +08:00
//
// This Source Code Form is subject to the terms of the MIT License.
// If a copy of the MIT was not distributed with this file,
// You can obtain one at https://github.com/gogf/gf.
package gvar
import (
2021-10-11 21:41:56 +08:00
"github.com/gogf/gf/v2/internal/utils"
2020-12-14 18:54:14 +08:00
)
2021-07-08 22:44:16 +08:00
// IsNil checks whether `v` is nil.
2020-12-14 18:54:14 +08:00
func (v *Var) IsNil() bool {
2021-07-08 22:44:16 +08:00
return utils.IsNil(v.Val())
2020-12-14 18:54:14 +08:00
}
2021-07-08 22:44:16 +08:00
// IsEmpty checks whether `v` is empty.
2020-12-14 18:54:14 +08:00
func (v *Var) IsEmpty() bool {
2021-07-08 22:44:16 +08:00
return utils.IsEmpty(v.Val())
2020-12-14 18:54:14 +08:00
}
2021-07-08 22:44:16 +08:00
// IsInt checks whether `v` is type of int.
2020-12-14 18:54:14 +08:00
func (v *Var) IsInt() bool {
2021-07-08 22:44:16 +08:00
return utils.IsInt(v.Val())
2020-12-14 18:54:14 +08:00
}
2021-07-08 22:44:16 +08:00
// IsUint checks whether `v` is type of uint.
2020-12-14 18:54:14 +08:00
func (v *Var) IsUint() bool {
2021-07-08 22:44:16 +08:00
return utils.IsUint(v.Val())
2020-12-14 18:54:14 +08:00
}
2021-07-08 22:44:16 +08:00
// IsFloat checks whether `v` is type of float.
2020-12-14 18:54:14 +08:00
func (v *Var) IsFloat() bool {
2021-07-08 22:44:16 +08:00
return utils.IsFloat(v.Val())
2020-12-14 18:54:14 +08:00
}
2021-07-08 22:44:16 +08:00
// IsSlice checks whether `v` is type of slice.
2020-12-14 18:54:14 +08:00
func (v *Var) IsSlice() bool {
2021-07-08 22:44:16 +08:00
return utils.IsSlice(v.Val())
2020-12-14 18:54:14 +08:00
}
2021-07-08 22:44:16 +08:00
// IsMap checks whether `v` is type of map.
2020-12-14 18:54:14 +08:00
func (v *Var) IsMap() bool {
2021-07-08 22:44:16 +08:00
return utils.IsMap(v.Val())
2020-12-14 18:54:14 +08:00
}
2021-07-08 22:44:16 +08:00
// IsStruct checks whether `v` is type of struct.
2020-12-14 18:54:14 +08:00
func (v *Var) IsStruct() bool {
2021-07-08 22:44:16 +08:00
return utils.IsStruct(v.Val())
2020-12-14 18:54:14 +08:00
}