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

     1  package converters
     2  
     3  import (
     4  	"strconv"
     5  
     6  	"gitlab.com/evatix-go/core/constants"
     7  	"gitlab.com/evatix-go/core/constants/bitsize"
     8  	"gitlab.com/evatix-go/core/errcore"
     9  )
    10  
    11  func StringToFloat64(input string) (value float64, err error) {
    12  	value, err2 := strconv.ParseFloat(input, bitsize.Of64)
    13  
    14  	if err2 != nil {
    15  		reference := input +
    16  			constants.NewLineUnix +
    17  			err2.Error()
    18  
    19  		return constants.Zero, errcore.
    20  			ParsingFailedType.Error(
    21  			errcore.FailedToConvertType.String(),
    22  			reference)
    23  	}
    24  
    25  	return value, err
    26  }