Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsNullOrEmpty ¶
IsNullOrEmpty checks if the provided value is nil or empty. It returns true if the value is nil, an empty string, or an empty slice (including arrays and maps). It returns false otherwise.
Supported types: - nil: Always returns true. - string: Returns true if the string is empty (""). - slice: Returns true if the slice has no elements. - map: Returns true if the map has no elements. - array: Returns true if the array has no elements. - pointer: Returns true if the pointer is nil.
Example usage:
package main
import (
"fmt"
"github.com/inuoshios/nullorempty"
)
func main() {
fmt.Println(nullorempty.IsNullOrEmpty(nil)) // true
fmt.Println(nullorempty.IsNullOrEmpty("")) // true
fmt.Println(nullorempty.IsNullOrEmpty("Hello")) // false
fmt.Println(nullorempty.IsNullOrEmpty([]int{})) // true
fmt.Println(nullorempty.IsNullOrEmpty(map[string]int{})) // true
fmt.Println(nullorempty.IsNullOrEmpty([]int{1, 2})) // false
}
Returns: - bool: true if the value is nil or empty, false otherwise.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.