github.com/go-email-validator/go-email-validator@v0.0.0-20230409163946-b8b9e6a0552e/pkg/ev/utils/utils.go (about) 1 package utils 2 3 import ( 4 "github.com/joho/godotenv" 5 "log" 6 "reflect" 7 ) 8 9 // RangeLen returns length of interface{} 10 func RangeLen(i interface{}) int { 11 if i == nil { 12 return 0 13 } 14 15 return reflect.ValueOf(i).Len() 16 } 17 18 // Errs forms []error from errors... 19 func Errs(errs ...error) []error { 20 if errs == nil || len(errs) == 1 && errs[0] == nil { 21 return nil 22 } 23 24 return errs 25 } 26 27 // LoadEnv loads 28 func LoadEnv(env string) { 29 filenames := make([]string, 0) 30 31 if env != "" { 32 filenames = append(filenames, env) 33 } 34 35 if err := godotenv.Load(filenames...); err != nil { 36 log.Print("No .env file found") 37 } 38 } 39 40 // StructName returns name of structure 41 func StructName(strct interface{}) string { 42 return reflect.ValueOf(strct).Type().String() 43 }