Documentation On “All Known Implementation” of Interfaces

后端 未结 3 1586
礼貌的吻别
礼貌的吻别 2021-02-05 18:03

Few months into learning Go, I just discover that os.File implements the io.Reader interface by implementing the Read(b []byte) (n int, err error) function. This allows me to us

3条回答
  •  有刺的猬
    2021-02-05 18:23

    https://github.com/dominikh/implements can do this:

    implements is a command line tool that will tell you which types implement which interfaces, or which interfaces are implemented by which types.

    e.g.

    ~ implements -types=crypto/cipher
    crypto/cipher.StreamReader implements...
            io.Reader
    *crypto/cipher.StreamReader implements...
            io.Reader
    crypto/cipher.StreamWriter implements...
            io.Closer
            io.WriteCloser
            io.Writer
    *crypto/cipher.StreamWriter implements...
            io.Closer
            io.WriteCloser
            io.Writer
    

提交回复
热议问题