Type semantics

Default constant types

Untyped boolean, rune, integer, floating, complex and string constants default to bool, rune, int, float64, complex128 and string respectively. The value must fit its default type when that type is required. Example output: 'int float64 int32'.

Formal Syntax & Structure

go syntaxgo
value := constant

Working Example

Example Snippetgo
package main
import "fmt"
func main() {  x := 7  y := 2.5  z := 'A'  fmt.Printf("%T %T %T\n", x, y, z)}
Go Reference