<jupyter_start><jupyter_text>一致性检查<jupyter_code>type UID interface {
    GetUID() int
}

type named interface {
    getName() string
}

type flower struct {
    Name string
}

func (f flower) getName() string {
    return f.Name
}
var rose = flower{"Rose"}
var i interface{} = rose
_, isPId := i.(UID)
isPId
_, isNamed := i.(named)
isPId<jupyter_output><empty_output><jupyter_text>接口继承<jupyter_code>type vehicle interface {
    getMaxSpeed() int
}
type truck interface {
    vehicle
    getCapacity() int
}
type kamaz struct {}

func (k kamaz) getMaxSpeed() int {
    return 85
}

func (k kamaz) getCapacity() int {
    return 8000
}
var k = kamaz{}
var capacity = k.getCapacity()
var v = vehicle(k)
var maxSpeed = v.getMaxSpeed()
maxSpeed
capacity<jupyter_output><empty_output><jupyter_text>接口集合<jupyter_code>type named interface {
    getName() string
}

type Sity struct {
    Name string
}

func (s Sity) getName() string {
    return s.Name
}

type Star struct {
    Name string
}

func (s Star) getName() string {
    return s.Name
}
var rows = []named {
    Sity{"Rome"},
    Star{"Sirius"},
}
var list = ""
for _, row := range rows {
    if len(list) > 0 {
        list += ", "
    }
    list += row.getName()
}
list<jupyter_output><empty_output><jupyter_text>方法要求<jupyter_code>type car interface {
    startEngine() bool
    stopEngine()
}

type sportCar struct {
    started bool
}

func (c *sportCar) startEngine() bool {
    if c.started {
        rt
    }
}<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12333333333333334, 'fraction_numerical': 0.004666666666666667, 'mean_word_length': 3.5075075075075075, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 18, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '407941', 'license': 'MIT', 'n_tokens_mistral': 564, 'n_tokens_neox': 554, 'n_words': 141, 'path': 'notebook/basic/interface.ipynb', 'repo_name': 'jasonlift/gophercises', 'size': '1500'}