genmain

package
Version: v0.0.0-...-a0b01fe Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2021 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

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

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

type Option func(*Generator)

Option a generator option definition

func API

func API(API *design.APIDefinition) Option

API The API definition

func DesignPkg

func DesignPkg(designPkg string) Option

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

func Force

func Force(force bool) Option

Force Whether to override existing files

func OutDir

func OutDir(outDir string) Option

OutDir Path to output directory

func Regen

func Regen(regen bool) Option

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

func Target

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