Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to support interface in goctl? #4125

Open
Linde7777 opened this issue May 7, 2024 · 1 comment
Open

Is it possible to support interface in goctl? #4125

Linde7777 opened this issue May 7, 2024 · 1 comment

Comments

@Linde7777
Copy link

Linde7777 commented May 7, 2024

Is your feature request related to a problem? Please describe.
I need to write unit-test, which need gomock, and it need interface

Describe the solution you'd like

package logic

type UserLogic interface {
	UserCreate(in *user.UserReq) (*user.UserResp, error)
	UserDelete(in *user.UserReq) (*user.UserResp, error)
}

type UserLogicV1 struct {
	UserRepo repository.UserRepository
}

// compile-time checking if UserLogicV1 implement UserLogic interface
var _ UserLogic = (*UserLogicV1)(nil)

// return the concrete implementation instead of interface, as Go style suggests
func NewUserLogicV1(userRepo repository.UserRepository) *UserLogicV1 {
	return &UserLogicV1{
		UserRepo: userRepo,
	}
}

Describe alternatives you've considered
currently no

Additional context
currently no

@Linde7777 Linde7777 changed the title It is possible to support interface(in Object-oriented programming) in goctl? Is it possible to support interface(in Object-oriented programming) in goctl? May 7, 2024
@Linde7777 Linde7777 changed the title Is it possible to support interface(in Object-oriented programming) in goctl? Is it possible to support interface in goctl? May 7, 2024
@kesonan
Copy link
Collaborator

kesonan commented May 11, 2024

not support yet, and no plan to support, define a template in logic.tpl maybe a good choice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants