diff --git a/10-interfaces/main.go b/10-interfaces/main.go index 2ac750d..57ba26f 100644 --- a/10-interfaces/main.go +++ b/10-interfaces/main.go @@ -3,31 +3,31 @@ package main import "fmt" type Animal interface { - Shout() string + Gritar() string } -type Cow struct{} +type Vaca struct{} -func (c *Cow) Shout() string { +func (c *Vaca) Gritar() string { return "Muuu" } -type Dog struct{} +type Cachorro struct{} -func (d *Dog) Shout() string { +func (d *Cachorro) Gritar() string { return "Rau rau!" } func main() { var animal Animal - animal = &Cow{} - callMyAnimal(animal) + animal = &Vaca{} + chamarMeuAnimal(animal) - animal = &Dog{} - callMyAnimal(animal) + animal = &Cachorro{} + chamarMeuAnimal(animal) } -func callMyAnimal(a Animal) { - fmt.Println("My animal says:", a.Shout()) +func chamarMeuAnimal(a Animal) { + fmt.Println("Meu animal diz:", a.Gritar()) } diff --git a/5-structs/main.go b/5-structs/main.go index 7ffedd9..0642ace 100644 --- a/5-structs/main.go +++ b/5-structs/main.go @@ -2,19 +2,19 @@ package main import "fmt" -type Person struct { - Name string - Age int - Active bool +type Pessoa struct { + Nome string + Idade int + Ativo bool } func main() { - p := Person{ - Name: "Wilson Júnior", - Age: 24, - Active: true, + p := Pessoa{ + Nome: "Wilson Júnior", + Idade: 24, + Ativo: true, } - fmt.Println("Nome", p.Name) - fmt.Println("Age", p.Age) - fmt.Println("Active", p.Active) + fmt.Println("Nome", p.Nome) + fmt.Println("Idade", p.Idade) + fmt.Println("Ativo", p.Ativo) } diff --git a/8-maps/main.go b/8-maps/main.go index 273fa31..1dc57fa 100644 --- a/8-maps/main.go +++ b/8-maps/main.go @@ -3,17 +3,17 @@ package main import "fmt" func main() { - people := map[string]int{ + pessoas := map[string]int{ "wilson": 25, "andre": 26, } - people["junior"] = 10 + pessoas["junior"] = 10 - for name, age := range people { - fmt.Printf("Chave %s do mapa valor: %d\n", name, age) + for nome, idade := range pessoas { + fmt.Printf("Chave %s do mapa valor: %d\n", nome, idade) } - delete(people, "wilson") - fmt.Printf("Posição não alocada: %d\n", people["wilson"]) + delete(pessoas, "wilson") + fmt.Printf("Posição não alocada: %d\n", pessoas["wilson"]) } diff --git a/9-methods/main.go b/9-methods/main.go index f08d873..4d5c808 100644 --- a/9-methods/main.go +++ b/9-methods/main.go @@ -2,33 +2,33 @@ package main import "fmt" -type Person struct { - Name string - Age int +type Pessoa struct { + Nome string + Idade int } -func (p *Person) String() string { - if p.Age < 18 { - return fmt.Sprintf("Olá jovem %s, seja bem vindo", p.Name) - } else if p.Age > 50 { - return fmt.Sprintf("Olá senhor %s, seja bem vindo", p.Name) +func (p *Pessoa) String() string { + if p.Idade < 18 { + return fmt.Sprintf("Olá jovem %s, seja bem vindo", p.Nome) + } else if p.Idade > 50 { + return fmt.Sprintf("Olá senhor %s, seja bem vindo", p.Nome) } - return fmt.Sprintf("Olá %s, seja bem vindo", p.Name) + return fmt.Sprintf("Olá %s, seja bem vindo", p.Nome) } -func (p *Person) privateMethod() int { - return p.Age * 4 +func (p *Pessoa) privateMethod() int { + return p.Idade * 4 } func main() { - person := Person{Name: "júnior", Age: 17} - fmt.Println(person.String()) + pessoa := Pessoa{Nome: "júnior", Idade: 17} + fmt.Println(pessoa.String()) - person = Person{Name: "Wilson", Age: 27} + pessoa = Pessoa{Nome: "Wilson", Idade: 27} fmt.Println(person.String()) - person = Person{Name: "Antônio", Age: 60} + pessoa = Pessoa{Nome: "Antônio", Idade: 60} fmt.Println(person.String()) }