Keyword

Go const keyword

Binds a name to a compile-time constant. Constants may be typed or untyped and cannot hold arbitrary runtime values. Example prints the fixed cost of three tickets.

Formal Syntax & Structure

go syntaxgo
const Name [Type] = constantExpression

Working Example

Example Snippetgo
package main
import "fmt"
func main() {  const unit = 7  fmt.Println(3 * unit)}
Go Reference