mirror of
https://github.com/projectdiscovery/nuclei.git
synced 2025-12-18 01:55:28 +00:00
* Merge from parent # Conflicts: # v2/cmd/nuclei/main.go # v2/internal/runner/config.go # v2/internal/runner/templates.go # v2/internal/runner/update.go # v2/pkg/templates/compile.go # v2/pkg/templates/compile_test.go # v2/pkg/types/types.go
44 lines
808 B
Go
44 lines
808 B
Go
package utils
|
|
|
|
import (
|
|
"reflect"
|
|
"strings"
|
|
)
|
|
|
|
func isEmpty(value interface{}) bool {
|
|
if value == nil {
|
|
return true
|
|
}
|
|
|
|
reflectValue := reflect.ValueOf(value)
|
|
actualValueInterface := reflectValue.Interface()
|
|
|
|
switch reflect.TypeOf(value).Kind() {
|
|
case reflect.String:
|
|
reflectedValue := actualValueInterface.(string)
|
|
return strings.TrimSpace(reflectedValue) == ""
|
|
case reflect.Slice, reflect.Array:
|
|
return reflectValue.Len() == 0
|
|
case reflect.Int32:
|
|
return IsEmpty(string(actualValueInterface.(rune)))
|
|
default:
|
|
if reflectValue.IsZero() {
|
|
return true
|
|
}
|
|
return false
|
|
}
|
|
}
|
|
|
|
func IsEmpty(value ...interface{}) bool {
|
|
for _, current := range value {
|
|
if IsNotEmpty(current) {
|
|
return false
|
|
}
|
|
}
|
|
return true
|
|
}
|
|
|
|
func IsNotEmpty(value interface{}) bool {
|
|
return !isEmpty(value)
|
|
}
|