golang的nil

golang中什么样的类型可以赋值nil? 类型文档中有注定"uninitialized value is nil"的类型都可以赋值nil.

golang的基本类型不能赋值nil:

    bool

    int

    uint

    float

    complex

    byte

    rune

    string

    struct

golang的非基本类型都能赋值nil:

    array

    slice

    map

    chan

    func

    interface

golang的指针类型也能赋值nil:

    pointer

其中struct令我最费解

posted @ 2016-09-07 13:35  zolo®  阅读(671)  评论(0编辑  收藏  举报