Configuration files
Gelidus edited this page Jan 24, 2016
·
1 revision
Configuration files are basically main files, that define what base resources are used to invoke which generators to produce code.
This is simple example of the configuration file:
package main
import (
"github.com/gophergala2016/gogen"
"github.com/gophergala2016/gogen/generator"
"github.com/gophergala2016/gogen/model"
)
func main() {
// Define resources that should be available to
// generators.
gogen.Define(model.User)
// set output for the generator
generator.Model.SetOutputDir("./model")
// Define pipes that should be run
gogen.Pipe(
generator.Model,
)
// start the generator
if err := gogen.Generate(); err != nil {
panic(err)
}
}
You can see, it consists of some blocks:
- firstly we define resources that we want to work with via the
Define()
function - (optional) next, we can setup the generators in case they provide customization methods
- now we define the pipes via
Pipe()
function. This allows us to share resources between generators - start the generator