A user-defined type gives a domain concept its own name and type. In Go, `type Magnitude float32` defines a type whose underlying type is `float32`. The compiler treats `Magnitude` and `float32` as distinct, so mixing their values requires an explicit conversion. That distinction helps prevent an unrelated number from being used as a measurement by accident. section 5.1 section 5.1.1
A defined type is not a type alias. `type A = B` supplies another name for the same type, leaving `A` and `B` interchangeable. A defined type creates a distinct type and can have its own methods. Both forms have uses, but choose a defined type when the distinction carries meaning in the program. section 5.1.1
Model recipe data
Declare `type Unit string` for measurement units and `type Ingredient string` for ingredient names. Although both are backed by strings, their names express different roles. A `Measurement` struct can group a magnitude with a unit; a `Recipe` struct can group a title, yield, and steps. Defined slice and map types can then represent an ingredient list, a recipe box, or a grocery list. section 5.1.1 section 5.2.2
Build larger models by composing smaller types rather than treating every value as a primitive. Embedding a general measurement in specialized types shares its fields and methods; methods and interfaces can then supply behaviors such as converting measurements and scaling recipes. section 5.2.1 section 5.6.2




