genmain

package
v1.4.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 23, 2019 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

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.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Generate

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

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

func GenerateController added in v1.2.0

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

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

Types

type Generator

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
	Regen     bool                  // Whether to regenerate scaffolding in place, maintaining controller implementation
	// contains filtered or unexported fields
}

Generator is the application code generator.

func NewGenerator added in v1.2.0

func NewGenerator(options ...Option) *Generator

NewGenerator returns an initialized instance of a JavaScript Client Generator

func (*Generator) Cleanup

func (g *Generator) Cleanup()

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

func (*Generator) Generate

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

Generate produces the skeleton main.

type Option added in v1.2.0

type Option func(*Generator)

Option a generator option definition

func API added in v1.2.0

func API(API *design.APIDefinition) Option

API The API definition

func DesignPkg added in v1.2.0

func DesignPkg(designPkg string) Option

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

func Force added in v1.2.0

func Force(force bool) Option

Force Whether to override existing files

func OutDir added in v1.2.0

func OutDir(outDir string) Option

OutDir Path to output directory

func Regen added in v1.3.0

func Regen(regen bool) Option

Regen Whether to regenerate scaffolding in place, maintaining existing controller implementation

func Target added in v1.2.0

func Target(target string) Option

Target Name of generated "app" package

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL