Home » Go Constants

Go Constants

A constant const contains data which is not changed. This data can only be of type boolean, number (integer, float or complex) or string.

Syntax:

Example:

The type specifier [type] is optional, the compiler can implicitly derive the type from the value.

Explicit Typing Example:

Implicit Typing Example:

Go Constant Example

Output:

value of area : 20000 

Next TopicGo Type Casting

You may also like