int } type Cercle struct { point rayon float64 } func (c Cercle) perimetre() float64 { return 2*c.rayon*math.Pi } func main() { c := Cercle{point{x:2,y:9},12} fmt.Fprintf(os.Stdout,"Cercle de centre (%d,%d) et de rayon %f perimetre %f\n",c.x,c.y,c.rayon,c.perimetre()) }
lien explicite entre un type et une interface type Cercle struct { point rayon float64 } func (c Cercle) perimetre() float64 { return 2*c.rayon*math.Pi } type Figure interface { perimetre() float64 }