You yourself quoted:
The iota mechanism has its limits. For example, it is not possible to create more familiar 1000 credentials (KB, MB, etc.), since there is no exponential operator.
The authors do not want you to still find a way, even though they did not know anything. The authors want you to create permanent ads for KB, MB, etc. As compact as possible.
With floating point literals
Here's a compact way. It uses exponential floating point literals . Think about it: the 1e3 record 1e3 even shorter than the 1000 record (not to mention the rest ...).
It also compresses all identifiers into one constant specification, so we reduce the signs = to 1.
Here it is just one line ( 67 characters without spaces):
const ( KB, MB, GB, TB, PB, EB, ZB, YB = 1e3, 1e6, 1e9, 1e12, 1e15, 1e18, 1e21, 1e24 )
Note that since we used floating point literals, constant identifiers ( KB , MB ...) denote floating point constants, even if the fractional parts of the literals are zero.
With a whole literal, using KB as a factor
If we need untyped integer constants, we must write 1000 for KB . And to get the next one, we will automatically move on to multiplying the previous identifier by 1000 . But note that we can also multiply the next by KB , because it's exactly 1000 - but shorter by two characters :).
So here are the declarations of untyped integer constants ( 77 characters without spaces):
const (KB,MB,GB,TB,PB,EB,ZB,YB = 1000,KB*KB,MB*KB,GB*KB,TB*GB,PB*KB,EB*KB,ZB*KB)
(Sorry to remove the spaces, but wanted it to fit on one line.)
With an integer literal, using the extra x const as a factor
You can even get 3 characters from the last solution if you also enter a const x length of 1 char, which you use several times to do the multiplication instead of *KB :
With optional x const ( 74 characters without spaces):
const (x,KB,MB,GB,TB,PB,EB,ZB,YB = 1000,x,x*x,MB*x,GB*x,TB*GB,PB*x,EB*x,ZB*x)
With rune literal
We can even shorten it another character if we specify the constant 1000 as a rune constant, with a rune whose code point 1000 , which is 'Ϩ' is 1 character less :)
With rune literal 'Ϩ' const ( 73 characters without spaces):
const (x,KB,MB,GB,TB,PB,EB,ZB,YB = 'Ϩ',x,x*x,MB*x,GB*x,TB*GB,PB*x,EB*x,ZB*x)
Note that these will be rune constants, but like all other numerical constants, they represent arbitrary precision values and do not overflow.