Created
November 23, 2018 17:45
-
-
Save miladvafaeifard/7444587b2d2148723a456f67c61dda06 to your computer and use it in GitHub Desktop.
test golang
This file contains hidden or 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 Person interface { | |
getName() string | |
} | |
func (e Employee) getName() string { | |
return e.name | |
} | |
type Employee struct { | |
name string | |
age int | |
} | |
func main() { | |
people := []Person{ | |
Employee{"Milad", 23}, | |
Employee{"Sara", 31}, | |
} | |
for _, p := range people { | |
fmt.Println("Hello " + p.getName()) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment