Zero value in Golang Last Updated : 12 Jul, 2025 Comments Improve Suggest changes Like Article Like Report In Go language, whenever we allocate memory for a variable with the help of declaration or by using new and if the variable is not initialized explicitly, then the value of such types of variables are automatically initialized with their zero value. The initialization of the zero value is done recursively. So, every element of the array of the structs has its fields zero if they are not specified with any value. Following are the zero values for different types of variables: Type Zero Value Integer 0 Floating point 0.0 Boolean false String "" Pointer nil Interface nil Slice nil Map nil Channel nil Function nil Example 1: C // Go program to illustrate the concept of zero value package main import "fmt" // Main Method func main() { // Creating variables // of different types var q1 int var q2 float64 var q3 bool var q4 string var q5 []int var q6 *int var q7 map[int]string // Displaying the zero value // of the above variables fmt.Println("Zero value for integer types: ", q1) fmt.Println("Zero value for float64 types: ", q2) fmt.Println("Zero value for boolean types: ", q3) fmt.Println("Zero value for string types: ", q4) fmt.Println("Zero value for slice types: ", q5) fmt.Println("Zero value for pointer types: ", q6) fmt.Println("Zero value for map types: ", q7) } Output: Zero value for integer types: 0 Zero value for float64 types: 0 Zero value for boolean types: false Zero value for string types: Zero value for slice types: [] Zero value for pointer types: <nil> Zero value for map types: map[] Example 2: C // Go program to check the variable // contains zero value or not package main import "fmt" func main() { // Creating variables of different types var q1 int = 2 var q2 float64 var q3 bool var q4 string // Slice var q5 []int // Pointer var q6 *int // Map var q7 map[int]string // Checking if the given variables // contain their zero value or not if q1 == 0 { fmt.Println("True") } else { fmt.Println("False") } if q2 == 0 { fmt.Println("True") } else { fmt.Println("False") } if q3 == false { fmt.Println("True") } else { fmt.Println("False") } if q4 == "" { fmt.Println("True") } else { fmt.Println("False") } if q5 == nil { fmt.Println("True") } else { fmt.Println("False") } if q6 == nil { fmt.Println("True") } else { fmt.Println("False") } if q7 == nil { fmt.Println("True") } else { fmt.Println("False") } } Output: False True True True True True True Create Quiz Comment A ankita_saini Follow 0 Improve A ankita_saini Follow 0 Improve Article Tags : Go Language Golang Explore OverviewGo Programming Language (Introduction) 7 min read How to Install Go on Windows? 3 min read How to Install Golang on MacOS? 4 min read Hello World in Golang 3 min read FundamentalsIdentifiers in Go Language 3 min read Go Keywords 2 min read Data Types in Go 7 min read Go Variables 9 min read Constants- Go Language 6 min read Go Operators 9 min read Control StatementsGo Decision Making (if, if-else, Nested-if, if-else-if) 5 min read Loops in Go Language 5 min read Switch Statement in Go 2 min read Functions & MethodsFunctions in Go Language 3 min read Variadic Functions in Go 3 min read Anonymous function in Go Language 2 min read main and init function in Golang 2 min read What is Blank Identifier(underscore) in Golang? 3 min read Defer Keyword in Golang 3 min read Methods in Golang 3 min read StructureStructures in Golang 7 min read Nested Structure in Golang 3 min read Anonymous Structure and Field in Golang 3 min read ArraysArrays in Go 7 min read How to Copy an Array into Another Array in Golang? 3 min read How to pass an Array to a Function in Golang? 2 min read SlicesSlices in Golang 14 min read Slice Composite Literal in Go 3 min read How to sort a slice of ints in Golang? 2 min read How to trim a slice of bytes in Golang? 3 min read How to split a slice of bytes in Golang? 3 min read StringsStrings in Golang 7 min read How to Trim a String in Golang? 2 min read How to Split a String in Golang? 3 min read Different ways to compare Strings in Golang 2 min read PointersPointers in Golang 8 min read Passing Pointers to a Function in Go 3 min read Pointer to a Struct in Golang 3 min read Go Pointer to Pointer (Double Pointer) 4 min read Comparing Pointers in Golang 3 min read ConcurrencyGoroutines - Concurrency in Golang 2 min read Select Statement in Go Language 4 min read Multiple Goroutines 2 min read Channel in Golang 7 min read Unidirectional Channel in Golang 2 min read Like