You’ll likely remember that certain built-in functions can sometimes evaluate to constants, rather than variables. For example:
var x [10]int
var y []int
len(x) // evaluates to a constant at compile time
len(y) // evaluates to a variable at runtime
Package unsafe
…
A (variable of) type
Thas variable size ifTis a type parameter, or if it is an array or struct type containing elements or fields of variable size. Otherwise the size is constant. Calls toAlignof,Offsetof, andSizeofare compile-time constant expressions of typeuintptrif their arguments (or the structsin the selector expressions.fforOffsetof) are types of constant size.
So here we have a few other special case examples of functions that can evaluate to constants at compile time, depending on the arguments passed to them.
Quotes from The Go Programming Language Specification Language version go1.23 (June 13, 2024)