Skip to content

Commit ce89a5d

Browse files
committed
nil update
1 parent 473f390 commit ce89a5d

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

EN/null-judge.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
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
1616
### Common practice in golang standard library: if err! = nil
1717

18+
### In the official document of go, nil is a predefined identifier, representing zero value of pointer, channel, function, interface, map or slice, not a reserved keyword of go
19+
### Nil can only be assigned to a variable of type pointer, channel, func, interface, map or slice (non base type) otherwise, panic will be raised
1820

1921
### usual type nil
2022

zh_CN/null-judge.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
### 不能单纯地判断一个struct是不是nil,因为它永远不可能是nil,可以通过返回一个error来判断是否为空,
1616
### golang标准库里的常见做法:if err != nil
1717

18+
### Go官方文档中,nil是预定义的标识符,代表指针、通道、函数、接口、映射或切片的零值,非 GO 的保留关键字
19+
### nil只能赋值给指针、channel、func、interface、map或slice类型的变量 (非基础类型) 否则会引发 panic
20+
1821
### 常见类型的 nil
1922

2023
```

0 commit comments

Comments
 (0)