gogen

package
v2.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2022 License: MIT Imports: 16 Imported by: 47

Documentation

Index

Constants

This section is empty.

Variables

View Source
var TemplateHelpers = map[string]interface{}{}

Functions

func AddGlobal added in v2.0.14

func AddGlobal(gf genny.File, globals ...string) (genny.File, error)

AddGlobal adds global variables.

func AddImport

func AddImport(gf genny.File, imports ...string) (genny.File, error)

AddImport adds n number of import statements into the path provided

func AddInsideBlock

func AddInsideBlock(gf genny.File, search string, expressions ...string) (genny.File, error)

AddInsideBlock will add anything inside of the app declaration block inside of file

func Append

func Append(gf genny.File, expressions ...string) (genny.File, error)

Append allows to append source into a go file

func Fmt

func Fmt(root string) (*genny.Generator, error)

func FmtTransformer

func FmtTransformer() genny.Transformer

func GoFiles

func GoFiles(dir string) ([]string, error)

func ReplaceBlock added in v2.0.14

func ReplaceBlock(gf genny.File, open, close, newOpen, newClose string) (genny.File, error)

ReplaceBlock replaces found block with given new open/close statements

open - start statement of the block e.g. `if isTrue {`
close - close statement of the block e.g. `}`
newOpen - new start statement of the block e.g. `defer func(isTrue) {`
newClose - new close statement of the block e.g. `}()`

func ReplaceBlockBody

func ReplaceBlockBody(gf genny.File, search string, expressions ...string) (genny.File, error)

ReplaceBlockBody will replace found block body with expressions passed

func RewriteImports

func RewriteImports(gf genny.File, swaps map[string]string) (genny.File, error)

func TemplateTransformer

func TemplateTransformer(data interface{}, helpers map[string]interface{}) genny.Transformer

TemplateTransformer will run any file that has a ".tmpl" extension through text/template

Types

type ParsedFile

type ParsedFile struct {
	File    genny.File
	FileSet *token.FileSet
	Ast     *ast.File
	Lines   []string
}

func ParseFile

func ParseFile(gf genny.File) (ParsedFile, error)

func ParseFileMode

func ParseFileMode(gf genny.File, mode parser.Mode) (ParsedFile, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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