gitlab.com/evatix-go/core@v1.3.55/coreutils/stringutil/ToInt.go (about)

     1  package stringutil
     2  
     3  import (
     4  	"strconv"
     5  )
     6  
     7  func ToInt(
     8  	s string,
     9  	defVal int,
    10  ) int {
    11  	toInt, err := strconv.Atoi(s)
    12  
    13  	if err != nil {
    14  		return defVal
    15  	}
    16  
    17  	return toInt
    18  }