All links of one day
in a single page.
<Previous day - Next day>

rss_feedDaily RSS Feed
floral_left The Daily Shaarli floral_right
——————————— December 10, 2017 - Sunday 10, December 2017 ———————————
interfaces - python - golang -

la version python pour comparer

golang - go - interfaces -

Les interfaces en go c'est vraiment pas simple ... Pour citer l'article :

Go’s interfaces are one of it’s best features, but they’re also one of the most confusing for newbies.

mais l'exemple est assez parlant :

type Walker interface {
    Walk(miles int)
}

type Camel struct {
    Name string
}

func (c Camel) Walk(miles int) {
     fmt.Printf(“%s is walking %v miles\n”, c.Name, miles)
}

func LongWalk(w Walker) {
     w.Walk(500)
     w.Walk(500)
}

func main() {
    c := Camel{“Bill”}
    LongWalk(c)
}

// prints
// Bill is walking 500 miles.
// Bill is walking 500 miles.
-