Golang : convert(cast) float to string



Tags : golang float string

This is an add-on to this previous tutorial on converting/casting int to string. To convert or cast a float value to string, just use the strconv.FormatFloat function.

 package main

 import "fmt"
 import "strconv"


 func main() {

 str := strconv.FormatFloat(12342323.234232, 'f', 6, 64)

 fmt.Println(str)
 }

Reference :

http://golang.org/pkg/strconv/#FormatFloat

Affiliate :

Hire Golang Developers




Tags : golang float string

By Adam Ng

IF you gain some knowledge or the information here solved your programming problem. Please consider donating to the less fortunate or some charities that you like. Apart from donation, planting trees, volunteering or reducing your carbon footprint will be great too.


Advertisement