goa: github.com/goadesign/goa/goagen/gen_main Index | Files

package genmain

import "github.com/goadesign/goa/goagen/gen_main"

Package genmain provides a generator for a skeleton goa application. This generator generates the code for a basic "main" package and is mainly intended as a way to bootstrap new applications. The generator creates a main.go file and one file per resource listed in the API metadata. If a file already exists it skips its creation unless the flag --force is provided on the command line in which case it overrides the content of existing files.


Package Files

doc.go generator.go options.go

func Generate Uses

func Generate() (files []string, err error)

Generate is the generator entry point called by the meta generator.

func GenerateController Uses

func GenerateController(force bool, appPkg, outDir, pkg, name string, r *design.ResourceDefinition) (string, error)

GenerateController generates the controller corresponding to the given resource and returns the generated filename.

type Generator Uses

type Generator struct {
    API       *design.APIDefinition // The API definition
    OutDir    string                // Path to output directory
    DesignPkg string                // Path to design package, only used to mark generated files.
    Target    string                // Name of generated "app" package
    Force     bool                  // Whether to override existing files
    // contains filtered or unexported fields

Generator is the application code generator.

func NewGenerator Uses

func NewGenerator(options ...Option) *Generator

NewGenerator returns an initialized instance of a JavaScript Client Generator

func (*Generator) Cleanup Uses

func (g *Generator) Cleanup()

Cleanup removes all the files generated by this generator during the last invokation of Generate.

func (*Generator) Generate Uses

func (g *Generator) Generate() (_ []string, err error)

Generate produces the skeleton main.

type Option Uses

type Option func(*Generator)

Option a generator option definition

func API Uses

func API(API *design.APIDefinition) Option

API The API definition

func DesignPkg Uses

func DesignPkg(designPkg string) Option

DesignPkg Path to design package, only used to mark generated files.

func Force Uses

func Force(force bool) Option

Force Whether to override existing files

func OutDir Uses

func OutDir(outDir string) Option

OutDir Path to output directory

func Target Uses

func Target(target string) Option

Target Name of generated "app" package

Package genmain imports 11 packages (graph) and is imported by 5 packages. Updated 2017-04-18. Refresh now. Tools for package owners.