typcfg

package
v0.9.21 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateAndLoadDotEnv

func GenerateAndLoadDotEnv(target string, c *Context) error

GenerateAndLoadDotEnv to create and load envfile

func GenerateDoc added in v0.9.17

func GenerateDoc(target string, c *Context) error

GenerateDoc generate usage document

Types

type Context

type Context struct {
	*typgo.Context
	Configs []*Envconfig
	Imports map[string]string
}

Context of config

type Envconfig

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

Envconfig model

type EnvconfigAnnot added in v0.9.17

type EnvconfigAnnot 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`
	GenDotEnv string // Dotenv path. It will be generated if not empty
	GenDoc    string // Usage documentation path. It will be if not emtpy
}

EnvconfigAnnot handle @envconfig annotation e.g. `@envconfig (prefix: "PREFIX" ctor:"CTOR")`

func (*EnvconfigAnnot) Annotation added in v0.9.21

func (m *EnvconfigAnnot) Annotation() *typgen.Annotation

func (*EnvconfigAnnot) Context added in v0.9.17

func (m *EnvconfigAnnot) Context(c *typgo.Context, directive typgen.Directives) *Context

Context create context instance

func (*EnvconfigAnnot) Process added in v0.9.17

func (m *EnvconfigAnnot) Process(c *typgo.Context, directives typgen.Directives) error

Annotate Envconfig to prepare dependency-injection and env-file

type EnvconfigTmplData

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

EnvconfigTmplData template

type Field

type Field struct {
	Key      string
	Default  string
	Required bool
}

Field model

func CreateField

func CreateField(prefix string, field *typgen.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