gotemplate
gotemplate copied to clipboard
[WIP] First cut of support for multiple source files
Depends on #16; hence marking this as WIP until that is merged/resolved.
Allows source package to contain multiple .go
files, but requires that exactly one file (the template) in that set contain a template "header":
// template type ...
(I have an immediate requirement for this; can easily work on multi-input multi-output as a follow up to this)
This looks good! I've been meaning to do this for ages!
This produces a single output file for all the input as far as I can see. I think that is the right choice - no need to clutter the users directory with generated code.
The docs need updating too for this (remove the docs about the restriction and document that only one file can have the template type definitions)
Also we should probably make a new test which makes two input files.
Thanks for the feedback @ncw
As I mentioned my current scenario is where there are multiple input files but only one which forms the basis of the template (the others are the result of code generation applied to the template itself, something that's required for the template to compile)
So that's nice and simple because we can effectively ignore the files that do not contain the template "header", e.g.:
// template type Set(A)
Grouping files in a package by unique template "headers" would also be a way of having multiple templates per package (requirement being that a .go
file contains at most one template header, else the package is in error)
The multi-input multi-output case is more complex for sure. That's not an immediate use case for me so I'm thinking through this case a bit more...
#16 is merged now - can you rebase this and add some docs then I'll merge :-)
Thanks
How are you getting on with this?
@ncw apologies - it's still on my TODO list. Getting bogged down with other things at the moment...
No problems!