Pi Value in Go: What is Golang pi

You can use the “math.Pi” constant from the standard library math package to get the pi(π) value in Golang. The math.Pi constant returns the 3.141592653589793″, which is the float64 value.

Example

package main

import (
  "fmt"
  "math"
)

func main() {
  pi := math.Pi
  fmt.Println(pi)
}

Output

3.141592653589793

This value is only an approximation of pi and may not be precise to all decimal places.

The Pi is a built-in Go constant of the math package used to get the value of the mathematical constant π. It is defined in Euclidean geometry as the ratio of a circle’s circumference to its diameter and also has various equivalent definitions.