Files
build-web-application-with-…/th/code/src/apps/ch.2.6/stringer_interface/main.go
2019-01-08 15:54:55 +07:00

23 lines
360 B
Go

package main
import (
"fmt"
"strconv"
)
type Human struct {
name string
age int
phone string
}
// Human implemented fmt.Stringer
func (h Human) String() string {
return "Name:" + h.name + ", Age:" + strconv.Itoa(h.age) + " years, Contact:" + h.phone
}
func main() {
Bob := Human{"Bob", 39, "000-7777-XXX"}
fmt.Println("This Human is : ", Bob)
}