Skip to content

Instantly share code, notes, and snippets.

@monkrus
Last active January 16, 2020 01:13
Show Gist options
  • Select an option

  • Save monkrus/976f858101c25b8aa29ae86ad67b8090 to your computer and use it in GitHub Desktop.

Select an option

Save monkrus/976f858101c25b8aa29ae86ad67b8090 to your computer and use it in GitHub Desktop.
Go lang composition
package main
import (
"fmt"
)
func main() {
b := Bird{}
b.Gender ="male"
b.Name = "Emu"
b.Origin = "Australia"
b.SpeedKPH = 48
b.CanFly = false
fmt.Println(b.Name, b.Gender)
}
type Animal struct {
Name string
Origin string
}
type Bird struct {
Animal
SpeedKPH float32
CanFly bool
Gender string
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment