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

package genclient

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

Package genclient provides a generator for the client tool and package of a goa application. The generator creates a main.go file and a subpackage containing data structures specific to the service.

The generated code includes a client package with:

* One client method per resource action
* Helper functions to build the corresponding request paths
* Structs for the action payloads and dependent types
* Structs for the action media types and corresponding decoder functions

The generated code also includes a CLI tool with commands for each action and sub-commands for each resource.


Package Files

cli_generator.go 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.

type Generator Uses

type Generator struct {
    API         *design.APIDefinition // The API definition
    OutDir      string                // Path to output directory
    Target      string                // Name of generated package
    ToolDirName string                // Name of tool directory where CLI main is generated once
    Tool        string                // Name of CLI tool
    NoTool      bool                  // Whether to skip tool generation
    // 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 Go 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 generats the client package and CLI.

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 NoTool Uses

func NoTool(noTool bool) Option

NoTool Whether to skip tool generation

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 package

func Tool Uses

func Tool(tool string) Option

Tool Name of CLI tool

func ToolDirName Uses

func ToolDirName(toolDirName string) Option

ToolDirName Name of tool directory where CLI main is generated once

Package genclient imports 15 packages (graph) and is imported by 10 packages. Updated 2018-04-21. Refresh now. Tools for package owners.