Skip to content

Instantly share code, notes, and snippets.

@abourget
Last active March 5, 2016 03:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save abourget/06c803e1e9e102f7dec4 to your computer and use it in GitHub Desktop.
Save abourget/06c803e1e9e102f7dec4 to your computer and use it in GitHub Desktop.
In my package's `gen/` folder
package main
import (
"fmt"
"strings"
_ "github.com/abourget/featurette/design"
"github.com/goadesign/goa/design"
"github.com/goadesign/goa/dslengine"
"github.com/goadesign/goa/goagen/gen_app"
"github.com/goadesign/goa/goagen/gen_swagger"
)
// Call with: "go run gen/main.go" from project root
func main() {
dslengine.FailOnError(dslengine.Errors)
dslengine.FailOnError(dslengine.Run())
apidesign := dslengine.Roots[0].(*design.APIDefinition)
genapp.TargetPackage = "app"
failOrPrint(new(genapp.Generator).Generate(apidesign))
failOrPrint(new(genswagger.Generator).Generate(apidesign))
// run custom generators...
}
func failOrPrint(files []string, err error) {
dslengine.FailOnError(err)
fmt.Println(strings.Join(files, "\n"))
}
@abourget
Copy link
Author

abourget commented Mar 1, 2016

Alternatively, the "make([]interface{}..." could be done by the Generator, if it so requires.. if the interface of dslengine should always be a []interface{} .. then I'd have a func in the dslengine to do that.. instead of here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment