Skip to content

Instantly share code, notes, and snippets.

@bolilla
Created June 8, 2015 06:54
Show Gist options
  • Save bolilla/f681808cd18e4c16966f to your computer and use it in GitHub Desktop.
Save bolilla/f681808cd18e4c16966f to your computer and use it in GitHub Desktop.
GoPadawan CompoInterfaces Interfaz
package main
import "fmt"
type motor struct {
ruido string
}
func (n motor) hacerRuido() string {
return fmt.Sprintf("Este motor hace: %s", n.ruido)
}
type cosaRuidosa interface {
hacerRuido() string
}
func main() {
var ruidoso cosaRuidosa
ruidoso = motor{"¡Brrroum!"}
fmt.Println(ruidoso.hacerRuido())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment