bump github.com/Kichiyaki/goutil, use reflect in models.isZero

This commit is contained in:
Dawid Wysokiński 2021-05-04 20:10:21 +02:00
parent 6fc7af4b50
commit cade63a9b7
3 changed files with 5 additions and 36 deletions

2
go.mod
View File

@ -7,7 +7,7 @@ require (
github.com/Kichiyaki/appmode v0.0.0-20210502105643-0a26207c548d
github.com/Kichiyaki/ginlogrus v0.0.0-20210502060406-bb0049cc40c4
github.com/Kichiyaki/go-pg-logrus-query-logger/v10 v10.0.0-20210502060056-ad595ba7b858
github.com/Kichiyaki/gopgutil/v10 v10.0.0-20210504171356-3135b02acf60
github.com/Kichiyaki/gopgutil/v10 v10.0.0-20210504180357-3f12426cbdaf
github.com/Kichiyaki/goutil v0.0.0-20210504132659-3d843a787db7
github.com/agnivade/levenshtein v1.1.0 // indirect
github.com/dgrijalva/jwt-go v3.2.0+incompatible

2
go.sum
View File

@ -12,6 +12,8 @@ github.com/Kichiyaki/gopgutil/v10 v10.0.0-20210504165554-36c969b33585 h1:V+/fHDt
github.com/Kichiyaki/gopgutil/v10 v10.0.0-20210504165554-36c969b33585/go.mod h1:MSAEhr8oeK+Rhjhqyl31/8/AI88thYky80OyD8mheDA=
github.com/Kichiyaki/gopgutil/v10 v10.0.0-20210504171356-3135b02acf60 h1:5f0EdZ15CSXDviRRBc8gR86f6uEPhUubyaUskV6ZFl0=
github.com/Kichiyaki/gopgutil/v10 v10.0.0-20210504171356-3135b02acf60/go.mod h1:MSAEhr8oeK+Rhjhqyl31/8/AI88thYky80OyD8mheDA=
github.com/Kichiyaki/gopgutil/v10 v10.0.0-20210504180357-3f12426cbdaf h1:FP1xooTbED1QcQGPyCha0Yukc4b1D5XJ70pvnL2NOT0=
github.com/Kichiyaki/gopgutil/v10 v10.0.0-20210504180357-3f12426cbdaf/go.mod h1:MSAEhr8oeK+Rhjhqyl31/8/AI88thYky80OyD8mheDA=
github.com/Kichiyaki/goutil v0.0.0-20210502095630-318d17091eab/go.mod h1:+HhI932Xb0xrCodNcCv5GPiCjLYhDxWhCtlEqMIJhB4=
github.com/Kichiyaki/goutil v0.0.0-20210504132659-3d843a787db7 h1:OU3ZA5H8fHTzaYIw9UBfH3gtWRL0XmnczlhH3E2PjV4=
github.com/Kichiyaki/goutil v0.0.0-20210504132659-3d843a787db7/go.mod h1:+HhI932Xb0xrCodNcCv5GPiCjLYhDxWhCtlEqMIJhB4=

View File

@ -1,42 +1,9 @@
package models
import (
"time"
"reflect"
)
func isZero(v interface{}) bool {
switch c := v.(type) {
case string:
return c == ""
case *string:
return c == nil
case []string:
return c == nil || len(c) == 0
case []Role:
return c == nil || len(c) == 0
case int:
return c == 0
case *int:
return c == nil
case []int:
return c == nil || len(c) == 0
case float64:
return c == 0
case *float64:
return c == nil
case float32:
return c == 0
case *float32:
return c == nil
case bool:
return !c
case *bool:
return c == nil
case time.Time:
return c.IsZero()
case *time.Time:
return c == nil
default:
return false
}
return reflect.ValueOf(v).IsZero()
}