Standard library / go/constant

go/constant.Val()

Expose the underlying representation: bool, string, int64, *big.Int, *big.Rat or *big.Float. Complex and Unknown yield nil. Expected stdout: 'int64\n'.

Formal Syntax & Structure

go syntaxgo
func Val(x Value) any

Parameters & Attributes

NameTypeDescription
xValueInput constant or Go value as specified by the function.

Return Value

any

Expose the underlying representation: bool, string, int64, *big.

Working Example

Example Snippetgo
package main
import (  "fmt"  "go/constant")
func main() { fmt.Printf("%T\n", constant.Val(constant.MakeInt64(42))) }
Go Reference