Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created March 26, 2018 23:35
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 parzibyte/085c03e6da06b9b7d067d683957d31c4 to your computer and use it in GitHub Desktop.
Save parzibyte/085c03e6da06b9b7d067d683957d31c4 to your computer and use it in GitHub Desktop.
package main
import "fmt"
type Mascota struct{
edad int
nombre, raza string
sana bool
}
func (m *Mascota) ladrar() {
fmt.Printf("¡guau! me llamo %s y tengo %d años\n", m.nombre, m.edad)
}
func main() {
mascota := Mascota{
edad: 10,
nombre: "Guayaba",
raza: "Tampoco la conozco",
sana: true,
}
mascota.ladrar()
/*
Obtener su nombre y guardarlo en una variable
*/
nombre := mascota.nombre
fmt.Println("La mascota se llama ", nombre)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment