Syntax

Go Declare a Constant Syntax

In Go, declare a constant: declares a constant — const Max = 100

Quick Answer

Syntax
const Max = 100
GoSyntax

Declare a Constant

Code example
const Max = 100

Declares a constant.

Learn More

How to declare a constant in Go

  1. Open your Go file or editor.
  2. Copy the example, then replace its sample names and values for your code.

Go Declare a Constant Syntax

Use const Max = 100.

Related Syntax References

Frequently asked questions

What is the Go syntax for declare a constant?

Use this pattern: const Max = 100

Can I copy this Go code example?

Yes. Use Copy code and adapt the example to your program.

Is this Go syntax different on Mac or Windows?

No. The language syntax is the same across operating systems.

Official source · How we verify