golang

package
v0.10.3 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Block

type Block struct {
	Key   string   `json:"key"`
	Type  string   `json:"type"`
	Lines []string `json:"lines"`
}

func NewBlock

func NewBlock(k string, t string) *Block

func (*Block) Render

func (b *Block) Render() string

func (*Block) W

func (b *Block) W(l string, args ...any)

func (*Block) WB added in v0.9.7

func (b *Block) WB()

func (*Block) WE added in v0.9.7

func (b *Block) WE(indent int, prefix ...string)

type Blocks

type Blocks []*Block

type File

type File struct {
	Package string   `json:"package,omitempty"`
	Path    []string `json:"path,omitempty"`
	Name    string   `json:"name"`
	Imports Imports  `json:"imports"`
	Blocks  Blocks   `json:"blocks"`
}

func NewFile

func NewFile(pkg string, path []string, fn string) *File

func (*File) AddBlocks

func (f *File) AddBlocks(b ...*Block)

func (*File) AddImport

func (f *File) AddImport(i ...*Import)

func (*File) Render

func (f *File) Render(addHeader bool) (*file.File, error)

type Import

type Import struct {
	Type  ImportType
	Value string
	Alias string
}

func NewImport

func NewImport(t ImportType, v string) *Import

func (*Import) Equals added in v0.9.19

func (i *Import) Equals(x *Import) bool

func (*Import) Render added in v0.8.24

func (i *Import) Render() string

func (*Import) WithAlias added in v0.8.24

func (i *Import) WithAlias(a string) *Import

type ImportType

type ImportType string
const (
	ImportTypeInternal ImportType = "internal"
	ImportTypeExternal ImportType = "external"
	ImportTypeApp      ImportType = "app"
)

type Imports

type Imports []*Import

func (Imports) Add

func (i Imports) Add(imports ...*Import) Imports

func (Imports) ByType

func (i Imports) ByType(t ImportType) []string

func (Imports) Render

func (i Imports) Render() string

func (Imports) RenderHTML

func (i Imports) RenderHTML() string

type Template

type Template struct {
	Path    []string `json:"path,omitempty"`
	Name    string   `json:"name"`
	Imports Imports  `json:"imports"`
	Blocks  Blocks   `json:"blocks"`
}

func NewGoTemplate

func NewGoTemplate(path []string, fn string) *Template

func (*Template) AddBlocks

func (f *Template) AddBlocks(b ...*Block)

func (*Template) AddImport

func (f *Template) AddImport(i ...*Import)

func (*Template) Render

func (f *Template) Render(addHeader bool) (*file.File, error)

Jump to

Keyboard shortcuts

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