Skip to content

Instantly share code, notes, and snippets.

@lclpedro
Created May 12, 2023 20:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lclpedro/05722a11a514e4b79f044ab27cb9028f to your computer and use it in GitHub Desktop.
Save lclpedro/05722a11a514e4b79f044ab27cb9028f to your computer and use it in GitHub Desktop.
instagram: @codandonapratica
package main
import "fmt"
type Animal interface {
FazerSom() string
}
type Cachorro struct{}
func (c Cachorro) FazerSom() string {
return "🐶 Woof.. Woof.."
}
type Gato struct{}
func (g Gato) FazerSom() string {
return "🐯 Meow.. Meow.."
}
type Leao struct{}
func (l Leao) FazerSom() string {
return "🦁 Rrrrroooar.. Rrrrroooar.."
}
func FazerSom(a Animal) {
fmt.Println()
fmt.Println(a.FazerSom())
fmt.Println()
}
func main() {
cachorro := Cachorro{}
FazerSom(cachorro)
gato := Gato{}
FazerSom(gato)
leao := Leao{}
FazerSom(leao)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment