ironsmile / nedomi

Highly performant HTTP reverse proxy with efficient caching of big files
GNU General Public License v3.0
81 stars 9 forks source link

Support for additional modules #194

Closed mstoykov closed 8 years ago

mstoykov commented 8 years ago

Currently if someone decides to write their own modules they can do it and just put them in a directory for the given module. But running go generate will change types.go in order for the modules to be imported and useful. This means that it will be harder to do other changes and not accidentally commit types.go.

I propose that we add the possibility for the module_generator to inspect a predefined gitignored file, additional.list, with list of package names to be included in additional_types.go.

Illustrating example:

inside module_dir/additional.list:

example.com/modules/awesome
example.com/modules/super

inside module_dir/new.go

// module_dir documentation
package module_dir

//go:generate go run ../tools/module_generator/main.go -template "types.go.template" -output  "types.go"

//go:generate go run ../tools/module_generator/main.go -inputlist additional.list -template "additional_types.go.template" -output "additional_types.go"
  • will give all the sub directories inside module_dir to types.go.template as arguments
  • will give the contents of additional.list to additional_types.go.template as arguments

This means that the changes will be to the:

ironsmile commented 8 years ago

The example for go:generate comments is slightly wrong. It contains -output > "types.go" which, I think, is wrong.

mstoykov commented 8 years ago

yes - i fixed it

mstoykov commented 8 years ago

if the inputlist is empty file or missing, go generate will have to just log it without actually failing.