golang

package
v0.0.0-...-797e501 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2021 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddComponent

func AddComponent(parent *ast.File, compo *adl.Struct) (component *ast.Struct, _ error)

AddComponent transpiles the given component and may optionally create multiple additional helper types, like default implementations and configuration types.

func AddParseEnvFunc

func AddParseEnvFunc(fieldPrefix string, node *ast.Struct) (*ast.Func, error)

AddParseEnvFunc appends a method named "ParseEnv" which has the given struct as a pointer receiver and sets all defined environment variables to the environment one.

func AddParseFlagFunc

func AddParseFlagFunc(fieldPrefix string, node *ast.Struct) (*ast.Func, error)

AddParseFlagFunc appends a method named "ConfigureFlags" which has the given struct as a pointer receiver and sets all defined struct variables to the flag ones. The go flags package to be parsed by the according struct instance. The naming is <a>-<b>-<c> for the flags. On unix, camel case is discouraged, so we have only the alternatives of . _ or - and we decided for now, to use -.

func AddResetFunc

func AddResetFunc(node *ast.Struct) (*ast.Func, error)

AddResetFunc appends a method named "Reset" which has the given struct as a pointer receiver and sets all literals back to default.

func GlobalFlatName

func GlobalFlatName(n ast.NamedType) string

GlobalFlatName tries to generate a readable and globally unique name without evaluating the actual context.

func GlobalFlatName2

func GlobalFlatName2(n ast.TypeDecl) string

GlobalFlatName2 tries to generate a readable and globally unique name without evaluating the actual context.

func ImplementFunctions

func ImplementFunctions(from *ast.Interface, to *ast.Struct)

ImplementFunctions appends all interface methods to the given struct. Funcs with errors will return a not-implemented-error, otherwise a panic is raised.

func MakePkgPath

func MakePkgPath(frags ...string) string

MakePkgPath takes arbitrary fragments and creates a more or less idiomatic path of it.

func MakePrivate

func MakePrivate(str string) string

MakePrivate converts ABc to aBc. Special cases:

  • ID becomes id

func MakePublic

func MakePublic(str string) string

MakePublic converts aBc to ABc. Special cases:

  • id becomes ID

func MkFile

func MkFile(dst *ast.Prj, modName, pkgName, fname string) *ast.File

func ModName

func ModName(n ast.Node) string

ModName returns the modules name.

func PkgName

func PkgName(n ast.Node) string

PkgName returns the parents package name.

func PkgPathBase

func PkgPathBase(p string) string

PkgPathBase is like filepath.Base but always with /

func PkgPathDir

func PkgPathDir(p string) string

PkgPathDir is like filepath.Dir but always with /

func PkgRelativeName

func PkgRelativeName(n ast.Node) string

PkgRelativeName returns the relative path within the given module name.

func ShortModName

func ShortModName(n ast.Node) string

func SimulateDefaultJson

func SimulateDefaultJson(node *ast.Struct) (interface{}, error)

SimulateDefaultJson inspects the fields default values and estimates how a potential json serialization may look like. Better to call AddResetFunc before, to ensure more correctly defined default values.

Types

This section is empty.

Jump to

Keyboard shortcuts

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