How to print float value in golang?

Hi Friends 👋,

Welcome To aGuideHub! ❤️

Today, I’m going to show you how to print float value in the golang console, here we will use the fmt package to print value.

When we going to print float variable value, we have to pass %f in the Printf() method or we also can use the fmt.Print() method without passing %f.

Let’s write code.

package main
import "fmt"

func main() {
	fmt.Printf("%f\n", 23.65)

When we run the above code, you should show your float value in the golang console like the below image.

print, float, golang

Try it yourself

All the best 👍

Follow me on Twitter