You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

12 lines
251 B
Go

package gomock
func GetUserName(us UserService, id int) (string, error) {
// 使用依赖注入进来的具体结构体方法通常为需要mock的方法
user, err := us.GetUser(id)
if err != nil {
return "", err
}
return user.Name, nil
}