Declaration

Untyped constants

An untyped constant can be assigned to a compatible destination without explicit conversion when representable. A context without a specific target type selects its default type when a type is needed. Example output: 'uint8 float64'.

Formal Syntax & Structure

go syntaxgo
const Name = expression

Working Example

Example Snippetgo
package main
import "fmt"
func main() {  const limit = 12  var x uint8 = limit  var y float64 = limit  fmt.Printf("%T %T\n", x, y)}
Go Reference