Skip to content

Instantly share code, notes, and snippets.

@didi1246888
Created March 11, 2022 02:09
Show Gist options
  • Save didi1246888/eb4278e5a7857d94124b534eaa03b26a to your computer and use it in GitHub Desktop.
Save didi1246888/eb4278e5a7857d94124b534eaa03b26a to your computer and use it in GitHub Desktop.
package main
import "fmt"
type Person struct { // abstract field
name string
}
func (p *Person) getName() { // Encapsulation method
fmt.Println(p.name)
}
type Inherit struct { // inheritance
Person
}
func main() {
i := Inherit{Person{"night guard"}}
i.getName() // output night guard
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment