What does nil mean in golang?

后端 未结 7 1008
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-24 06:12

There are many cases using nil in golang. For example:

func (u *URL) Parse(ref string) (*URL, error) {
    refurl, err := Parse(ref)
    if          


        
7条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-24 06:49

    • For the data types like slice and pointers which "refer" to other types, "nil" indicates that the variable does not refer to an instance (equivalent of null pointer in other languages)
    • It is thee zero value of the variables of type functions, maps, interfaces, channels and structures

提交回复
热议问题