Zero value
A zero value is the default, type-dependent value assigned when a variable, field, or newly allocated value has no explicit initial value.
Learn Go with Pocket-Sized Projects
A zero value is the default value assigned to a Go variable or returned for an absent or uninitialized value of its type.
- How it is used
- Uses zero values to handle missing map entries and reason about initialization and API behavior.
- How deep it goes
- Explains lookup and initialization behavior through examples, without cataloging zero values for all types.
- Examples
- Uses a book counter, a greeting phrasebook, a generic cache, and a maze image lookup.
- What you can do after
- Apply zero-value behavior to check map membership, increment counters, and initialize a cache’s map.
Read how Learn Go with Pocket-Sized Projects explains zero value →
Go by Example
A zero value is the default value assigned to a Go variable when no explicit initializer is provided.
- How it is used
- Simplifies test environments and service types by removing unnecessary initialization before use.
- How deep it goes
- Explains practical zero-value design through builders, pointer nil panics, lazy map initialization, option ambiguity, and copying cautions.
- Examples
- Demonstrates testEnv with strings.Builder fields, nil pointer builders, and a Shortener that initializes its map on demand.
- What you can do after
- Apply zero-value-friendly type designs while handling nil maps, pointer initialization, ambiguous option defaults, and stateful-value copying.
100 C++ Mistakes and How to Avoid Them
A zero value is the type-dependent zero-initialized value assigned to an object or variable by a relevant initialization operation.
- How it is used
- Uses type-dependent values to initialize members and mark exclusive resources as invalid after transfer.
- How deep it goes
- Defines the value through initialization and resource-transfer examples, and warns about invalid states without detailing language mechanics.
- Examples
- Uses a Person age member and Channel socket resources to illustrate initialization and post-transfer invalid values.
- What you can do after
- Apply a detectable invalid value after resource transfer, while preserving the class invariant.
Read how 100 C++ Mistakes and How to Avoid Them explains zero value →
API Design Patterns
A zero value is the empty or numerically zero representation that a data format or type uses when no distinct null representation is available.
- How it is used
- Guides API field and default design when formats cannot represent null or missing primitive values.
- How deep it goes
- Explains Boolean, numeric, and map consequences, but defers numeric default handling to serialization design.
- Examples
- Uses ChatRoom permissions, allowChatbots, disallowChatbots, numeric zero, and empty-versus-null maps.
- What you can do after
- Evaluate API defaults for ambiguity, intentional zero values, predictable behavior, and future default changes.
Go in Action, Second Edition
A zero value is the default value assigned to a newly declared Go variable when no explicit initial value is provided.
- How it is used
- Uses default values to make declarations and map access immediately usable without mandatory initialization.
- How deep it goes
- Explains defaults and map behavior with runnable patterns, but defers other zero-value details to later treatment.
- Examples
- Demonstrates default integers, missing map entries, Boolean membership maps, and numeric word-count lookups.
- What you can do after
- Apply zero values in declarations and map lookups, and diagnose absent keys with two-value assignment.
Also covered in
What to know first
- referenceA reference is an indirect value, binding, or relationship that identifies or provides access to another object, value, resource, or source.
- booleanA Boolean is a logical value or data type representing truth or falsity, conventionally with the two values true and false.
- number typeA numeric type is a type whose values represent numbers with a defined representation and support numerical operations.
- structA struct is a named composite type or data structure that groups multiple fields or values into one structured unit.
Related concepts
- Mapproduced by · A map is an associative data structure that stores key-value associations and supports retrieving values by key.
- named result parameterused by · A named result parameter is a Go function result parameter declared with an identifier that can be referenced within the function body and is initialized to its type's zero value.
- valuekind of · A value is a quantity, datum, or measure of significance attributed to or represented by an entity, property, expression, or outcome.
- attributeconfigures · An attribute is a named property or piece of information associated with an entity, object, or structured data item.
Questions about zero value
What is zero value?
A zero value is the default, type-dependent value assigned when a variable, field, or newly allocated value has no explicit initial value.
Which Manning books explain zero value?
Learn Go with Pocket-Sized Projects, Go by Example, 100 C++ Mistakes and How to Avoid Them, API Design Patterns and Go in Action, Second Edition.
What should I know before learning zero value?
Manning books that teach zero value usually introduce reference, boolean, number type and struct first.
What is zero value a kind of?
Zero value is a kind of value. A value is a quantity, datum, or measure of significance attributed to or represented by an entity, property, expression, or outcome.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.




