package main
import (
"fmt"
)
type user struct {
name string
Age int
}
func (u user) getName() string {
return u.name
}
func (u user) getUserAge() string {
return fmt.Sprintf("%s is %d years old", u.getName(), u.Age)
}
// Contoh interface untuk kelas user
type IUserService interface {
getUserAge() string
}
// Implementasikan interface UserService
func NewUser(name string, age int) IUserService {
return user{name: name, Age: age}
}
func main() {
user := NewUser("John Lenon", 29)
fmt.Println(user.getUserAge())
}