Welcome To Golang By Example

Pi value in Go (Golang)

Table of Contents

Overview

math package of GO provides a Pi constant.


This is how it is defined in the constant.go file of math package. It is a float64 value

Pi  = 3.14159265358979323846264338327950288419716939937510582097494459

Code:

package main

import (
	"fmt"
	"math"
)

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

Output:

3.141592653589793