Use strconv.FormatFloat like such:

s := strconv.FormatFloat(3.1415, 'f', -1, 64)
fmt.Println(s)

Outputs

3.1415

Answer from Ullaakut on Stack Overflow
🌐
YourBasic
yourbasic.org › golang › convert-string-to-float
Convert between float and string · YourBasic Go
CODE EXAMPLE Use strconv.ParseFloat to parse a floating point number from a string, and fmt.Sprintf to format a float as a string.
Discussions

Problem converting float32 to string
HI I have problem with float32 to string conversion. My test code: package main import ( "fmt" "strconv" ) func main() { var t float32 t = 5.9902389 numeroString := strconv.FormatFloat(float64(t), 'f', -1, 32) fmt.Println("Number float32:", t) fmt.Println("Number string:", numeroString) } Responce: ... More on forum.golangbridge.org
🌐 forum.golangbridge.org
1
0
July 20, 2023
Converting a float to string
http://golang.org/pkg/strconv/#FormatFloat http://golang.org/pkg/strconv/#ParseFloat If you don't care about errors, write a small wrapper func. More on reddit.com
🌐 r/golang
5
3
November 20, 2014
How do you convert a float to string (SOLVED)
I am having a very tough time converting float to string. I am getting some data from GPS. The coordinates are in float. I want something like String gpsString; //Imma gonna call this function in the loop void checkG… More on forum.arduino.cc
🌐 forum.arduino.cc
14
1
May 30, 2014
Convert float to string without losing precision.
Use f-strings/format specifiers. num = 12.78 print(f'{num:.6f}') # prints 12.780000 The :.6f formats the float (f) num such that there are 6 decimal places. More on reddit.com
🌐 r/learnpython
5
1
February 23, 2021
🌐
TutorialsPoint
tutorialspoint.com › golang-program-to-convert-double-type-variables-to-string
Golang Program to convert double type variables to string
November 22, 2022 - FormatFloat ? this function is used to convert decimal numbers to strings. It takes four arguments the first one is the float number that we wish to convert followed by fmt and prec which are used to control the output and the last argument is the bitsize of integer result.
🌐
Go Forum
forum.golangbridge.org › getting help
Problem converting float32 to string - Getting Help - Go Forum
July 20, 2023 - My test code: package main import ( "fmt" "strconv" ) func main() { var t float32 t = 5.9902389 numeroString := strconv.FormatFloat(float64(t), 'f', -1, 32) fmt.Println("Number float32:", t) fmt.Println("Number string:", numeroString) } Responce: ...
🌐
Outside Online
outsideonline.com › adventure › snow sports › we hitched a ride with california’s only heli-skiing business
Heli-Skiing in California Seemed Like a Pipe Dream. Then These Two Guys Showed Up.
February 28, 2026 - My group’s guide, Max Wittenberg, points out a spot halfway down the run where we will reconnoiter. He tells us to keep a certain distance from each other, and to stay to the right of his tracks. ... Despite the low-angle, I speed down the run, my board floating over the canvas of soft snow.
🌐
Educative
educative.io › answers › how-can-we-convert-a-float-into-a-string-in-golang
How can we convert a float into a string in Golang
A float can be converted into a string, in Golang, using the following two functions: FormatFloat: This function is available within the strconv package. Sprintf: This function is available within the fmt package.
🌐
Go Packages
pkg.go.dev › strconv
strconv package - strconv - Go Packages
FormatComplex converts the complex number c to a string of the form (a+bi) where a and b are the real and imaginary parts, formatted according to the format fmt and precision prec. The format fmt and precision prec have the same meaning as in FormatFloat. It rounds the result assuming that the original was obtained from a complex value of bitSize bits, which must be 64 for complex64 and 128 for complex128. func FormatFloat(f float64, fmt byte, prec, bitSize int) string
Find elsewhere
🌐
Reddit
reddit.com › r/golang › converting a float to string
r/golang on Reddit: Converting a float to string
November 20, 2014 -

What is the easy way of converting a float to a string?

The strconv package seems awfully cluttered and there doesn't seem to be a function where you can simply give a float and get a string

🌐
GitHub
gist.github.com › morrxy › b5972d4516e1e41229aba77f85894942
[int float to string] #golang · GitHub
[int float to string] #golang. GitHub Gist: instantly share code, notes, and snippets.
🌐
Home Assistant
home-assistant.io › documentation › templating
Templating - Home Assistant
Start here if you are new to templating in Home Assistant. The pages below walk you through the concepts step by step. What templates are and why you would use them. The places in Home Assistant where templates show up. The building blocks of every template, explained in plain language. Making decisions and repeating work with if, for, and friends. Quoting, multi-line strings, and other YAML gotchas.
🌐
Scaler
scaler.com › home › topics › type casting in golang
Type Casting in Golang - Scaler Topics
September 28, 2023 - Type cast in golang is used to change a variable's data type. If you want to save a decimal value as a simple integer, you can typecast float to int, for instance. Values of one type can be transformed into another using the cast operator.
🌐
Admfactory
admfactory.com › home › how to convert a float to string in golang
How to convert a float to string in Golang | ADMFactory
June 11, 2020 - How to convert a float to a string in Golang using strconv.FormatFloat function.
🌐
WAFB
wafb.com › 2026 › 02 › 27 › louisiana-bill-would-penalize-aggressive-float-riders-during-mardi-gras-other-parades
Louisiana bill would penalize aggressive float riders during Mardi Gras, other parades
Frederique Bekale, owner of Cookies by Freddie, said the penalties may go too far. “Mardi Gras is a very fun time, but plenty of people are also drunk,” Bekale said. “They think they’re having fun. They’re trying to throw it forth so that someone in the back can catch it.
Published   February 27, 2026
🌐
Go
go.dev › src › math › big › floatconv.go
This file implements string-to-Float conversion functions.
189 func (z *Float) pow5(n uint64) *Float { 190 const m = uint64(len(pow5tab) - 1) 191 if n <= m { 192 return z.SetUint64(pow5tab[n]) 193 } 194 // n > m 195 196 z.SetUint64(pow5tab[m]) 197 n -= m 198 199 // use more bits for f than for z 200 // TODO(gri) what is the right number? 201 f := new(Float).SetPrec(z.Prec() + 64).SetUint64(5) 202 203 for n > 0 { 204 if n&1 != 0 { 205 z.Mul(z, f) 206 } 207 f.Mul(f, f) 208 n >>= 1 209 } 210 211 return z 212 } 213 214 // Parse parses s which must contain a text representation of a floating- 215 // point number with a mantissa in the given conversion base (the exponent 216 // is always a decimal number), or a string representing an infinite value.
🌐
W3Schools
w3schools.com › go › go_variables.php
W3Schools.com
In Go, there are different types of variables, for example: int- stores integers (whole numbers), such as 123 or -123 · float32- stores floating point numbers, with decimals, such as 19.99 or -19.99 · string - stores text, such as "Hello World".
🌐
TutorialsPoint
tutorialspoint.com › how-to-convert-string-to-float-type-in-golang
How to Convert string to float type in Golang?
May 5, 2023 - It returns the converted float value and an error value. Step 1 ? Import the strconv package. ... Step 2 ? Declare a string variable to store the string value.
🌐
Go Packages
pkg.go.dev › time
time package - time - Go Packages
Output: Absolute value of positive duration: 5s Absolute value of negative duration: 3s Absolute value of MinInt64 equal to MaxInt64: true ... Hours returns the duration as a floating point number of hours.
🌐
YourBasic
yourbasic.org › golang › round-float-2-decimal-places
Round float to 2 decimal places · YourBasic Go
Use strconv.ParseFloat to parse a floating point number from a string, and fmt.Sprintf to format a float as a string.