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

     1  package stringutil
     2  
     3  import "strconv"
     4  
     5  func ToBool(
     6  	s string,
     7  ) bool {
     8  	if s == "" {
     9  		return false
    10  	}
    11  
    12  	switch s {
    13  	case "yes", "Yes", "YES", "y", "1":
    14  		return true
    15  	case "no", "NO", "No", "0", "n":
    16  		return false
    17  	}
    18  
    19  	isBool, err := strconv.ParseBool(s)
    20  
    21  	if err != nil {
    22  		return false
    23  	}
    24  
    25  	return isBool
    26  }