github.com/flower-corp/rosedb@v1.1.2-0.20230117132829-21dc4f7b319a/util/str.go (about)

     1  package util
     2  
     3  import "strconv"
     4  
     5  // Float64ToStr Convert type float64 to string
     6  func Float64ToStr(val float64) string {
     7  	return strconv.FormatFloat(val, 'f', -1, 64)
     8  }
     9  
    10  // StrToFloat64 convert type string to float64
    11  func StrToFloat64(val string) (float64, error) {
    12  	return strconv.ParseFloat(val, 64)
    13  }
    14  
    15  // StrToInt64 converts type string to int64.
    16  func StrToInt64(val string) (int64, error) {
    17  	return strconv.ParseInt(val, 10, 64)
    18  }
    19  
    20  // StrToUint converts type string to uint64.
    21  func StrToUint(val string) (uint64, error) {
    22  	return strconv.ParseUint(val, 10, 64)
    23  }