Documentation
¶
Overview ¶
Package generator render go template, call external commands, generate gommon specific methods based on gommon.yml
Index ¶
Constants ¶
View Source
const ( // PkgName TODO: is reserved for the incoming library package (liblibrary?) to allow control logger etc. PkgName = "gommon" GommonConfigFile = "gommon.yml" Name = "gommon" DefaultGeneratedFile = "gommon_generated.go" )
Variables ¶
This section is empty.
Functions ¶
func DefaultIgnores ¶
func GenerateSingle ¶
GenerateSingle generates based on a single gommon.yml
Types ¶
type ConfigFile ¶ added in v0.0.8
type ConfigFile struct {
// Loggers is helper methods on struct for gommon/log to build a tree for logger, this is subject to change
Loggers []dlog.StructLoggerConfig `yaml:"loggers"`
// GoTemplates is templates written in go's text/template format, they are mainly used to generate go source file
GoTemplates []GoTemplateConfig `yaml:"gotmpls"`
// Noodles is the config for embedding assets by generating go file with a large byte slice
Noodles []noodle.EmbedConfig `yaml:"noodles"`
// Shells is shell commands to be executed
Shells []ShellConfig `yaml:"shells"`
// GoPackage override folder name for generated go file
GoPackage string `yaml:"go_package"`
// contains filtered or unexported fields
}
func NewConfigFile ¶ added in v0.0.8
func NewConfigFile(pkg string, file string) *ConfigFile
type GoTemplateConfig ¶
type GoTemplateConfig struct {
Src string `yaml:"src"`
Dst string `yaml:"dst"`
Go bool `yaml:"go"`
Data interface{} `yaml:"data"`
}
func (*GoTemplateConfig) Render ¶
func (c *GoTemplateConfig) Render(root string) error
type ShellConfig ¶ added in v0.0.5
type ShellConfig struct {
// Code is the command to be executed, Command will overwrite it if presented,
// it is kept for backward compatibility
Code string `yaml:"code"`
Command string `yaml:"command"`
// Shell is true, use sh -c, otherwise use exec on the first segment after split
Shell bool `yaml:"shell"`
// Cd is true, switch to the folder of config file when executing command
Cd bool `yaml:"cd"`
}
ShellConfig is shell command executed by gommon https://github.com/dyweb/gommon/issues/53
func (*ShellConfig) Render ¶ added in v0.0.5
func (c *ShellConfig) Render(root string) error
Render execute the shell command, redirect stdin/out/err and block until it is finished
Click to show internal directories.
Click to hide internal directories.