Last active
August 17, 2021 16:26
-
-
Save syafdia/31ca8f257a1cbea57ecd0f7ec89e05da 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
// internal/user/usecase.go | |
package user | |
import "context" | |
type RegisterUserUseCase interface { | |
Execute(ctx context.Context, input CreateUserInput) (User, error) | |
} | |
type registerUserUseCase struct { | |
userRepo UserRepo | |
} | |
func NewRegisterUserUseCase( | |
userRepo UserRepo, | |
) RegisterUserUseCase { | |
return ®isterUserUseCase{userRepo: userRepo} | |
} | |
func (w *registerUserUseCase) Execute(ctx context.Context, input CreateUserInput) (User, error) { | |
user, err := w.userRepo.Create(ctx, input) | |
if err != nil { | |
return User{}, err | |
} | |
// Do something | |
// ... | |
// ... | |
return user, nil | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment