How to find out which types implement which interface

前端 未结 2 849
南笙
南笙 2020-12-29 06:46

Example:

In package io the type ByteReader defines an interface that wraps the method ReadByte() (c byte, err error).

What is the

2条回答
  •  难免孤独
    2020-12-29 07:00

    Mostly by experience. Anyway, for example:

    jnml@fsc-r630:~/go/src/pkg$ egrep -nr '^func (.*) ReadByte\(' *
    bufio/bufio.go:165:func (b *Reader) ReadByte() (c byte, err error) {
    bytes/reader.go:59:func (r *Reader) ReadByte() (b byte, err error) {
    bytes/buffer.go:289:func (b *Buffer) ReadByte() (c byte, err error) {
    encoding/xml/xml_test.go:234:func (d *downCaser) ReadByte() (c byte, err error) {
    strings/reader.go:58:func (r *Reader) ReadByte() (b byte, err error) {
    jnml@fsc-r630:~/go/src/pkg$ 
    

    And also the golang.org site has a case sensitive search capability.

提交回复
热议问题