Standard library / go/constant
go/constant.Real()
Extract the real part of a numeric constant. Expected stdout: '2\n'.
Formal Syntax & Structure
go syntaxgo
func Real(x Value) ValueParameters & Attributes
| Name | Type | Description |
|---|---|---|
| x | Value | Input constant or Go value as specified by the function. |
Return Value
Value
Extract the real part of a numeric constant.
Working Example
Example Snippetgo
package main
import ( "fmt" "go/constant" "go/token")
func main() { v := constant.BinaryOp(constant.MakeInt64(2), token.ADD, constant.MakeImag(constant.MakeInt64(3))) fmt.Println(constant.Real(v))}