gitlab.com/evatix-go/core@v1.3.55/coreutils/stringutil/ToByteDefault.go (about) 1 package stringutil 2 3 import ( 4 "strconv" 5 6 "gitlab.com/evatix-go/core/constants" 7 ) 8 9 func ToByteDefault( 10 s string, 11 ) byte { 12 toInt, err := strconv.Atoi(s) 13 14 if err != nil { 15 return constants.Zero 16 } 17 18 if toInt >= constants.Zero && toInt <= constants.MaxUnit8AsInt { 19 return byte(toInt) 20 } 21 22 return constants.Zero 23 }