Search code examples
pointersgobigint

BigInt pointer in Go


I was playing around with various packages and data types and I came across this function(big.NewInt()) from "math/big" package. so this function returns a pointer to the type bigInt but when i print it out i get the actual value not the address where it is stored can anyone help me understand this better?

package main

import "fmt"
import "math/big"
import "reflect"

func main(){
    target := big.NewInt(1)
    a := 5
    s := &a
    fmt.Println(reflect.TypeOf(target))
    fmt.Println(reflect.TypeOf(s))
    fmt.Println(s)
    fmt.Println(target)
}

Solution

  • fmt.Printf("%p\n", target)      // 0xc00000c080