Created
August 2, 2020 00:24
-
-
Save luandevpro/dadad34e40a3ed77240e0e4fe1adcd20 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
) | |
type Do interface { | |
getName() string | |
getAge() int | |
} | |
type Student struct{ | |
name string | |
age int | |
} | |
func (t Student) getName() string { | |
return t.name | |
} | |
func (t Student) getAge() int { | |
return t.age | |
} | |
func main() { | |
student := Student{ | |
name: "tran", | |
age: 25, | |
} | |
var do Do = student | |
do.getName() | |
fmt.Println(do.getName()) | |
fmt.Println(do.getAge()) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment