1
0
mirror of https://github.com/ManyakRus/starter.git synced 2025-11-26 23:10:42 +02:00

сделал IsEmptyValue()

This commit is contained in:
Nikitin Aleksandr
2024-04-12 15:34:20 +03:00
parent 5cfb8cbc93
commit 6324c9b944
2 changed files with 26 additions and 0 deletions

View File

@@ -841,3 +841,10 @@ func StructDeepCopy(src, dist interface{}) (err error) {
}
return gob.NewDecoder(&buf).Decode(dist)
}
// IsEmptyValue - возвращает true если значение по умолчанию (0, пустая строка, пустой слайс)
func IsEmptyValue(v any) bool {
rv := reflect.ValueOf(v)
Otvet := !rv.IsValid() || reflect.DeepEqual(rv.Interface(), reflect.Zero(rv.Type()).Interface())
return Otvet
}