typcfg

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2020 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Stdout io.Writer = os.Stdout

Stdout standard output

Functions

func GenerateAndLoadDotEnv

func GenerateAndLoadDotEnv(target string, c *Context) error

GenerateAndLoadDotEnv to create and load envfile

func GenerateUsage

func GenerateUsage(target string, c *Context) error

GenerateUsage generate usage document

Types

type Context

type Context struct {
	*typast.Context
	Configs []*Envconfig
}

Context of config

type Envconfig

type Envconfig struct {
	CtorName string
	Prefix   string
	SpecType string
	Name     string
	Fields   []*Field
}

Envconfig model

type EnvconfigAnnotation

type EnvconfigAnnotation struct {
	TagName  string // By default is `@envconfig`
	Template string // By default defined in defaultCfgTemplate variable
	Target   string // By default is `cmd/PROJECT_NAME/envconfig_annotated.go`
	DotEnv   string // Dotenv path. It will be generated if not empty
	UsageDoc string // Usage documentation path. It will be if not emtpy
}

EnvconfigAnnotation handle @envconfig annotation e.g. `@envconfig (prefix: "PREFIX" ctor_name:"CTOR")`

func (*EnvconfigAnnotation) Annotate

func (m *EnvconfigAnnotation) Annotate(c *typast.Context) error

Annotate Envconfig to prepare dependency-injection and env-file

func (*EnvconfigAnnotation) Context

func (m *EnvconfigAnnotation) Context(c *typast.Context) *Context

Context create context instance

type EnvconfigTmplData

type EnvconfigTmplData struct {
	typast.Signature
	Package string
	Imports []string
	Configs []*Envconfig
}

EnvconfigTmplData template

type Field

type Field struct {
	Key      string
	Default  string
	Required bool
}

Field model

func CreateField

func CreateField(prefix string, field *typast.Field) *Field

CreateField create new instance of field

Jump to

Keyboard shortcuts

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