gitlab.com/evatix-go/core@v1.3.55/coreutils/stringutil/ToUint32Default.go (about) 1 package stringutil 2 3 import ( 4 "math" 5 "strconv" 6 7 "gitlab.com/evatix-go/core/constants" 8 ) 9 10 func ToUint32Default( 11 s string, 12 ) uint32 { 13 toInt, err := strconv.Atoi(s) 14 15 if err != nil { 16 return constants.Zero 17 } 18 19 // fix https://t.ly/6aoW, 20 // https://gitlab.com/evatix-go/core/-/issues/81 21 // use MaxInt32 instead of uint32Max 22 if toInt >= 0 && toInt <= math.MaxInt32 { 23 return uint32(toInt) 24 } 25 26 return constants.Zero 27 }