Documentation
¶
Overview ¶
Package printer implements printing of avo files in various formats.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// Command-line arguments passed to the generator. If provided, this will be
// included in a code generation warning.
Argv []string
// Name of the code generator.
Name string
// Name of Go package the generated code will belong to.
Pkg string
}
Config represents general printing configuration.
func NewArgvConfig ¶
func NewArgvConfig() Config
NewArgvConfig constructs a Config from os.Args. The package name is guessed from the current directory.
func NewDefaultConfig ¶
func NewDefaultConfig() Config
NewDefaultConfig produces a config with Name "avo". The package name is guessed from the current directory.
func NewGoRunConfig ¶
func NewGoRunConfig() Config
NewGoRunConfig produces a Config for a generator that's expected to be executed via "go run ...".
func (Config) GeneratedBy ¶
GeneratedBy returns a description of the code generator.
Example ¶
package main
import (
"fmt"
"github.com/mmcloughlin/avo/printer"
)
func main() {
// Default configuration named "avo".
cfg := printer.NewDefaultConfig()
fmt.Println(cfg.GeneratedBy())
// Name can be customized.
cfg = printer.Config{
Name: "mildred",
}
fmt.Println(cfg.GeneratedBy())
// Argv takes precedence.
cfg = printer.Config{
Argv: []string{"echo", "hello", "world"},
Name: "mildred",
}
fmt.Println(cfg.GeneratedBy())
}
Output: avo mildred command: echo hello world
func (Config) GeneratedWarning ¶
GeneratedWarning returns text for a code generation warning. Conforms to https://golang.org/s/generatedcode.
Click to show internal directories.
Click to hide internal directories.