typcfg

package
v0.9.14 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 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 GenerateUsage

func GenerateUsage(target string, c *Context) error

GenerateUsage generate usage document

Types

type Context

type Context struct {
	*typast.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 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:"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
	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 *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