gotemplate icon indicating copy to clipboard operation
gotemplate copied to clipboard

[WIP] First cut of support for multiple source files

Open myitcv opened this issue 7 years ago • 6 comments

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)

myitcv avatar Apr 28 '17 14:04 myitcv

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.

ncw avatar May 03 '17 09:05 ncw

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...

myitcv avatar May 03 '17 19:05 myitcv

#16 is merged now - can you rebase this and add some docs then I'll merge :-)

Thanks

ncw avatar May 07 '17 20:05 ncw

How are you getting on with this?

ncw avatar May 30 '17 14:05 ncw

@ncw apologies - it's still on my TODO list. Getting bogged down with other things at the moment...

myitcv avatar May 30 '17 14:05 myitcv

No problems!

ncw avatar May 30 '17 14:05 ncw