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

webrpc-gen fails to load templates with unknown template function(s) #148

Open
VojtechVitek opened this issue Nov 25, 2022 · 2 comments
Open
Assignees
Labels
bug Something isn't working

Comments

@VojtechVitek
Copy link
Contributor

failed to load templates from ../webrpc/gen-golang: template: struct.go.tmpl:23: function "trimPrefix" not defined

I thought we'd be able to require specific Template Functions API from within the templates & that's why we have introduced minVersion .WebrpcGenVersion "v0.7.0" function. However, it looks like Go templates look up all the functions up-front and fail early before even executing the template (no matter if the missing function would be executed or not).

We'll need to support this in some other way, so we have better & user-friendly errors.

@VojtechVitek VojtechVitek changed the title webrpc-gen fails to load templates on unknown template functions webrpc-gen fails to load templates with unknown template function(s) Nov 25, 2022
@VojtechVitek
Copy link
Contributor Author

VojtechVitek commented Nov 25, 2022

I think we could experiment with multiple template entrypoints:

  • "main" for the code-generation
  • "help" for printing help
  • "version" for printing minimal required webrpc-gen version
  • "schema" for printing required webrpc schema (v1 / v2 /...)

Instead of getting this generic error template: struct.go.tmpl:23: function "trimPrefix" not defined, I'd expect webrpc-gen to print something like

  • -target=golang@v0.8.0 requires v2 schema; please update your schema file
  • or -target=golang@v0.8.0 requires at least webrpc-gen v0.8.0+, please update webprc-gen

@VojtechVitek VojtechVitek self-assigned this Nov 25, 2022
@VojtechVitek VojtechVitek added the bug Something isn't working label Nov 25, 2022
@pkieltyka
Copy link
Member

Yes makes sense

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants