From 661d6fc3e185cf888e27948b806246e5558ce72a Mon Sep 17 00:00:00 2001 From: rosque Date: Sat, 12 Oct 2019 19:26:19 -0300 Subject: [PATCH 1/4] Update main.go --- 5-structs/main.go | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) 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) } From d5f3873e0fd85b4ae819e6e555ace8d02f81630a Mon Sep 17 00:00:00 2001 From: rosque Date: Sat, 12 Oct 2019 19:29:29 -0300 Subject: [PATCH 2/4] Update main.go --- 8-maps/main.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) 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"]) } From 313094830b3342be59c17a174f58e97601b47af6 Mon Sep 17 00:00:00 2001 From: rosque Date: Sat, 12 Oct 2019 19:36:15 -0300 Subject: [PATCH 3/4] Update main.go --- 9-methods/main.go | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) 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()) } From 6ae93a5cb638ae7e4043695ec535fcd581996472 Mon Sep 17 00:00:00 2001 From: rosque Date: Sat, 12 Oct 2019 19:40:33 -0300 Subject: [PATCH 4/4] Update main.go --- 10-interfaces/main.go | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) 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()) }