1
This commit is contained in:
parent
67c974caa2
commit
2418793e3d
10
convert.go
10
convert.go
@ -139,10 +139,18 @@ func ToStringEx(x interface{}) (string, error) {
|
|||||||
return "", errors.New("ToStringEx error type")
|
return "", errors.New("ToStringEx error type")
|
||||||
}
|
}
|
||||||
|
|
||||||
func DuckToSimple[T string | int32 | int64 | float32 | float64](
|
func DuckToSimple[T string | int | int32 | int64 | float32 | float64](
|
||||||
d interface{}, s *T) bool {
|
d interface{}, s *T) bool {
|
||||||
var sx interface{} = s
|
var sx interface{} = s
|
||||||
switch sv := sx.(type) {
|
switch sv := sx.(type) {
|
||||||
|
case *int:
|
||||||
|
{
|
||||||
|
if val, err := ToInt64Ex(d); err == nil {
|
||||||
|
*sv = int(val)
|
||||||
|
} else {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
case *int32:
|
case *int32:
|
||||||
{
|
{
|
||||||
if val, err := ToInt64Ex(d); err == nil {
|
if val, err := ToInt64Ex(d); err == nil {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user