A value that reaches the wrong code path can produce an error long after it was assigned. Go moves many such failures to the build: every value has a type, the compiler tracks it, and incompatible assignments are rejected before the program runs. Fast compilation makes that check part of the everyday development loop. section 1.2.2 section 1.0
Listing 1.2 Type mismatch caught at compile time
var number int var str string number = 1 str = "one" number = str // Error: cannot use str (variable of type string) as int in assignment
The final assignment tries to put a string into an int variable. The compiler reports the mismatch; the program never reaches that line at runtime. section 1.2.2
Type safety also shapes domain design. Named types can represent measurements and units; structs group recipe data; embedded types distinguish measurement concepts; and interfaces express shared behaviors such as scaling or conversion. These choices make the model clearer while giving the compiler more structure to check. section 5.0 section 5.6.2
Generics extend compile-time checking to reusable functions and collections without requiring a separate implementation for each type. Use them when the same logic serves multiple types or a result must preserve its contents’ exact type. If one concrete type suffices, or an interface already captures the needed behavior, simpler code is preferable. section 6.0 section 6.5.4







