Skip to content

Instantly share code, notes, and snippets.

@bketelsen
Forked from abourget/main.go
Created March 1, 2016 02:44
Show Gist options
  • Save bketelsen/087ba36984d172b9b9c5 to your computer and use it in GitHub Desktop.
Save bketelsen/087ba36984d172b9b9c5 to your computer and use it in GitHub Desktop.
Under my package's `gen` folder
package main
import (
"fmt"
"os"
"strings"
"github.com/goadesign/goa/dslengine"
"github.com/goadesign/goa/goagen/codegen"
"github.com/goadesign/goa/goagen/gen_app"
_ "github.com/abourget/featurette/design"
)
func main() {
// if possible, shrink that to a single call, too..
failOnError(dslengine.Errors)
failOnError(dslengine.Run())
// Now take the results and call the generator with it
// FIXME: reduce that to a single line
roots := make([]interface{}, len(dslengine.Roots))
for i, r := range dslengine.Roots {
roots[i] = r
}
codegen.OutputDir = "../test"
codegen.DesignPackagePath = "github.com/abourget/featurette/design"
// shrink these 3 lines to a single line too..
files, err := genapp.Generate(roots)
failOnError(err)
fmt.Println(strings.Join(files, "\n"))
failOrPrint(genswagger.Generate(roots))
failOrPrint(genmyown.Generate(roots))
}
// FIXME: move to `codegen` or something..
func failOnError(err error) {
if err != nil {
fmt.Fprintf(os.Stderr, "%s", err)
os.Exit(1)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment