golang

package
v0.8.6 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2023 License: MIT Imports: 5 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)

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
}

func NewImport

func NewImport(t ImportType, v 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