Literal

Imaginary literals

A numeric literal with suffix i denotes a pure imaginary constant. Combine it with a real constant to form a complex constant; the suffix is not a variable name. Example output: '3 2'.

Formal Syntax & Structure

go syntaxgo
2i; 1.5i; 0x2p1i

Working Example

Example Snippetgo
package main
import "fmt"
func main() {  z := 3 + 2i  fmt.Println(real(z), imag(z))}
Go Reference