Every variable declared without an explicit value in Go is automatically assigned its type's zero value, eliminating undefined behavior found in languages like C.
Go guarantees that every declared variable has a well-defined initial value called the zero value. This design choice eliminates a whole class of bugs common in C/C++ where uninitialized variables hold garbage memory values.
int, float64, byte, rune → 0
bool → false
string → "" (empty string)
pointer, slice, map, channel, function, interface → nil
struct → each field gets its own zero value recursively
Practical implication: you can safely use a struct before setting any field. A nil slice has len 0 and can be appended to. However, a nil map will panic on write — always initialize maps with make() before inserting keys.
You declare a struct with an int field and a string field but don’t assign values — what do those fields contain when you print them?
You create a slice and try to append to it without initializing it — what happens? Why?
A user service returns an empty list of orders — the frontend shows 'No orders' but the backend logs show a nil slice. Why is this a problem, and how do you fix it?
Your API endpoint returns a struct with a zero-valued Price field, but the client expects null for unset prices. How do you handle this without breaking existing clients?
You’re designing a caching layer that stores structs with optional metadata fields — how do you distinguish between a field being intentionally unset versus zero-valued, and what performance or correctness tradeoffs do you consider?
A distributed system uses zero-valued timestamps to indicate 'not set', but race conditions cause some nodes to interpret zero as 'epoch time'. How do you redesign this to avoid ambiguity at scale?
Your company’s legacy Go microservices rely heavily on zero values to represent optional fields, but now you’re migrating to a schema-driven API gateway that treats zero as explicit. How do you plan the migration without breaking hundreds of downstream services?
You’re designing a new data pipeline where zero values in metrics are indistinguishable from missing data — how do you architect the type system and serialization layer to support both semantic clarity and backward compatibility across teams?