Type semantics

Constant representability

An integer destination needs an integral value within its range. A floating destination permits rounding to its precision without overflow. A type parameter requires representability for every type in its set. Example output: '255'.

Formal Syntax & Structure

go syntaxgo
var name T = constant

Working Example

Example Snippetgo
package main
import "fmt"
func main() {  const n = 255  var b uint8 = n  fmt.Println(b)}
Go Reference