Go Structs (Part 2) — Zero Value Structs

Sher Chowdhury
Dec 21, 2020


A zero value struct is simply a struct variable where each key’s value is set to their respective zero value.

This article is part of the Structs in Go series.

We can create a zero value struct using the var statement to initialize our struct variable.


Line 15: This initializes a zero value struct variable. You can also write this line as dave := employee{}

Line 17: Primitive data types defaults to their respective zero values. For int, that is 0, and strings that it is an empty string (hence the big black space in the out put), and for booleans it is false.

Line 18: You can replace zero values with your own values.