i am trying to build a modular monolith.
each module has its own interface, struct etc.
import employeeService "myproject/internal/employee/service"
type AuthService interface {
SignUp(ctx context.Context, signUpRequest requests.SignUpRequest) (userId string, companyId string, role sharedModels.Role, err error)
CreateUser(ctx context.Context, tx *gorm.DB, createUserRequest *requests.UserCreationRequest) (user *models.User, err error)
}
type authService struct {
cfg *config.Config
userRepo repository.UserRepository
employeeService employeeService.EmployeeService
logger *log.Logger
}
func NewAuthService(cfg *config.Config, userRepo repository.UserRepository, employeeService employeeService.EmployeeService, logger *log.Logger) AuthService {
return &authService{
cfg: cfg,
userRepo: userRepo,
employeeService: employeeService,
logger: logger,
}
}
and
import authService "myproject/internal/auth/service"
type EmployeeService interface {
CreateUser(....
}
type employeeService struct {
cfg *config.Config
employeeRepo repository.EmployeeRepository
authService authService.AuthService
logger *log.Logger
}
func NewEmployeeService(cfg *config.Config, employeeRepo repository.EmployeeRepository, authService authService.AuthService, logger *log.Logger) EmployeeService {
return &employeeService{
cfg: cfg,
employeeRepo: employeeRepo,
authService: authService,
logger: logger,
}
}
I think maybe creating a new package called interfaces and moving the interfaces into it and then importing from there may work. But this would make me move my domain based packed logic move into "shared" packages.
Any idea ?
Thank you.