henryspace

记录精彩的程序人生 开始使用

Part 17 - Go 语言学习 - 接口的组合

接口的组合

  1. 接口可以通过组合别的接口,来集成别的接口的能力
type Seeker interface {
	Seek(offset int64, whence int) (int64, error)
}

// ReadWriter is the interface that groups the basic Read and Write methods.
type ReadWriter interface {
	Reader
	Writer
}

// ReadCloser is the interface that groups the basic Read and Close methods.
type ReadCloser interface {
	Reader
	Closer
}

// WriteCloser is the interface that groups the basic Write and Close methods.
type WriteCloser interface {
	Writer
	Closer
}
评论
留下你的脚步