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




Contact US

Email:[email protected]

Go Constants
10/30