Skip to content
配图

Go 接口

go
type Store interface {
    Save(ctx context.Context, b Blog) error
}

接口越小,mock 越简单。Go 习惯在用时定义接口,而非先画巨大 UML。

空接口 any 与泛型(Go 1.18+)分工:能类型参数化就别滥用 any

Visitors · Page views