Skip to content

Commit 473f390

Browse files
committed
nil type
1 parent 70b709c commit 473f390

File tree

4 files changed

+36
-2
lines changed

4 files changed

+36
-2
lines changed

EN/null-judge.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,20 @@
1313
### A struct null value is an empty Struct with "all members are null values" instead of nil,
1414

1515
### You cannot simply determine whether a struct is nil, because it can never be nil. You can determine whether it is empty by returning an error
16-
### Common practice in golang standard library: if err! = nil
16+
### Common practice in golang standard library: if err! = nil
17+
18+
19+
### usual type nil
20+
21+
```
22+
bool -> false
23+
numbers -> 0
24+
string -> ""
25+
26+
pointers -> nil
27+
slices -> nil
28+
maps -> nil
29+
channels -> nil
30+
functions -> nil
31+
interfaces -> nil
32+
```

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,4 @@ The notes only sort out some important and difficult-to-understand knowledge poi
2323

2424
#### zh_CN 中文
2525
[README_CN](https://github.com/iotd/jackliu-golang-notes/tree/master/zh_CN)
26+

zh_CN/goroutine/goroutine.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ func main() {
4040

4141

4242

43-
### goroutine usage
43+
### goroutine 用法
44+
45+
4446

4547

4648

zh_CN/null-judge.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,18 @@
1414

1515
### 不能单纯地判断一个struct是不是nil,因为它永远不可能是nil,可以通过返回一个error来判断是否为空,
1616
### golang标准库里的常见做法:if err != nil
17+
18+
### 常见类型的 nil
19+
20+
```
21+
bool -> false
22+
numbers -> 0
23+
string -> ""
24+
25+
pointers -> nil
26+
slices -> nil
27+
maps -> nil
28+
channels -> nil
29+
functions -> nil
30+
interfaces -> nil
31+
```

0 commit comments

Comments
 (0)