跳至主要內容
  • Hostloc 空間訪問刷分
  • 售賣場
  • 廣告位
  • 賣站?

4563博客

全新的繁體中文 WordPress 網站
  • 首頁
  • golang 关于 nil 的问题
未分類
6 11 月 2020

golang 关于 nil 的问题

golang 关于 nil 的问题

資深大佬 : Chaox 4

nil 的底层实现在源码中为:

// nil is a predeclared identifier representing the zero value for a // pointer, channel, func, interface, map, or slice type. var nil Type // Type must be a pointer, channel, func, interface, map, or slice type  // Type is here for the purposes of documentation only. It is a stand-in // for any Go type, but represents the same type for any given function // invocation. type Type int  

在源码中好像是 int 类型? 我的疑惑是 nil 在实际使用中是有类型区分的,可以把 nil 转换为不同类型的 nil 。那 nil 是接口类型还是 int 类型? 如果接口类型他的 data,type 是什么内容呢?如果是 int 类型底层实现又是如何呢?

大佬有話說 (2)

  • 資深大佬 : darksword21

    好问题,下回答

  • 資深大佬 : elechi

    理解成空指针就行
    // Type must be a pointer, channel, func, interface, map, or slice type
    对应的,上面这些其实都是指针类型

文章導覽

上一篇文章
下一篇文章

AD

其他操作

  • 登入
  • 訂閱網站內容的資訊提供
  • 訂閱留言的資訊提供
  • WordPress.org 台灣繁體中文

51la

4563博客

全新的繁體中文 WordPress 網站
返回頂端
本站採用 WordPress 建置 | 佈景主題採用 GretaThemes 所設計的 Memory
4563博客
  • Hostloc 空間訪問刷分
  • 售賣場
  • 廣告位
  • 賣站?
在這裡新增小工具