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

generic.Type support function definition ? #80

Open
achilsh opened this issue Jul 8, 2023 · 0 comments
Open

generic.Type support function definition ? #80

achilsh opened this issue Jul 8, 2023 · 0 comments

Comments

@achilsh
Copy link

achilsh commented Jul 8, 2023

i want to define function with generic.Type define. for example:
define template_demo.go :

  1. type ModelType generic.Type

func registerModelType() {
MngCreater = append(MngCreater, ModelType(GlobalmgDb))
}

  1. then run genny command:

input_file="./template_res_register.go"
out_file="res_register_1.go" ##
real_type="RegisterSignDailyFortuneMg,RegisterSecretChitchatWork" ###RegisterSecretChitchatWork
pkg_name="common_res"
genny -in ${input_file} -out ${out_file} -pkg ${pkg_name} gen "ModelType=${real_type}"

  1. then generated codes:

func registerRegisterSecretChitchatWork() {
MngCreater = append(MngCreater, RegisterSecretChitchatWork(GlobalmgDb))
}

  1. when i build project, error happen . show defined template file err:

cannot use ModelType(GlobalmgDb) (value of type ModelType) as data_cache.CreateRes value in argument to append: ModelType does not implement data_cache.CreateRes (missing method Create)

@achilsh achilsh changed the title generic.Type support function defintion? generic.Type support function definition ? Jul 8, 2023
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

1 participant