代码如下
```
type A struct {
}
func (this *A) Test() string {
return "123"
}
type C struct {
client *A
}
func main() {
c := C{}
log.Println(c.client.Test())
var a *A
log.Println(a.Test())
}
```
期望如 1.16.x会抛出 panic 错误才对
不知道为何1.17.x 为何会处理为正常输出
这样不是会出现更多坑吗
根据官方祖传代码显示,go天生就这样吧。
```go
// Close closes the File, rendering it unusable for I/O.
// On files that support SetDeadline, any pending I/O operations will
// be canceled and return immediately with an error.
// Close will return an error if it has already been called.
func (f *File) Close() error {
if f == nil {
return ErrInvalid
}
return f.file.close()
}
```
#4
更多评论
![image.png](https://static.studygolang.com/211230/0e67a319d05c3b6e07ce90bf28b7a053.png)
不对 我使用1.16.5也不报错
朋友的go就报错
![image.png](https://static.studygolang.com/211230/37e9d1251c23e52ec474e770b487b4ad.png)
#1
```
func (this *A) Test() string {
return "123"
}
```
不报错
报错 此报错我觉得是正常的毕竟没实例化
```
func (this A) Test() string {
return "123"
}
```
#2