gitlab.com/evatix-go/core@v1.3.55/converters/StringToFloat64Conditional.go (about)

     1  package converters
     2  
     3  import (
     4  	"strconv"
     5  
     6  	"gitlab.com/evatix-go/core/constants/bitsize"
     7  )
     8  
     9  func StringToFloat64Conditional(
    10  	input string, defaultFloat64 float64,
    11  ) (value float64, isSuccess bool) {
    12  	value, err2 := strconv.ParseFloat(input, bitsize.Of64)
    13  
    14  	if err2 != nil {
    15  		return defaultFloat64, false
    16  	}
    17  
    18  	return value, true
    19  }