In many programming languages, constants (e.g. literal numbers in the code) have an associated data type. In Go, constants are what I’ll call “Schrödinger-esque” in that they don’t have a type until they are “observed.” Observed here means read or written at run time.
Here’s an example I put together with strings: Go Playground - The Go Programming Language
In the example from the tour of Go, the constant, Big
, is defined as the value 1 << 100
. That expression means to take a 1 and shift its conceptual bit(s) to the left 100 positions. Most computers today are 64-bit, so a bit shifted 100 positions would “fall” right over the end and you’d end up with some invalid result like 0 or -1. If you were to then take that result and shift it back to the right 99 positions such as in the example of Small
’s definition, you’d end up with some other invalid and/or unexpected value.
My understanding of the purpose of the example is to show that when you’re working with constants, they don’t have a data type, so you can define huge constants and then build up other constants with expressions on previous ones (like how Small
is defined as Big >> 99
). It’s only when you try to use these constants in code that the datatype is decided based on the type of the variable the constant is being assigned to.