From 2ae54339797007c7248b645b20af2eecb87b3867 Mon Sep 17 00:00:00 2001 From: johnzhu0907 <90296451+johnzhu0907@users.noreply.github.com> Date: Thu, 13 Oct 2022 19:44:00 +0800 Subject: [PATCH] Update README.md Add zero values. Understanding the zero value of each type is good for a Golang developer to develop a robust Application. --- README.md | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 050db1b..9fab8cb 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,7 @@ * [Goroutines](#goroutines) * [Channels](#channels) * [Channel Axioms](#channel-axioms) +17. [Zero Values](#zero-values) 17. [Printing](#printing) 18. [Reflection](#reflection) * [Type Switch](#type-switch) @@ -688,7 +689,21 @@ func doStuff(channelOut, channelIn chan int) { } // 1 2 0 ``` - +# Zero Values +| Type | Zero Value | +| :------------- | :--------- | +| Integer | 0 | +| Floating point | 0.0 | +| Boolean | false | +| String | "" | +| Pointer | nil | +| Interface | nil | +| Slice | nil | +| Map | nil | +| Channel | nil | +| Function | nil | + +> The elements of an array or struct will have its fields zeroed if no value is specified. This initialization is done recursively ## Printing ```go