sdcodegen

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package sdcodegen 生成源代码

Index

Constants

View Source
const (
	I = Action("ignore")
	W = Action("write")
	C = Action("create")
)

Variables

This section is empty.

Functions

func Expand

func Expand(filename string) string

func SimplePrint

func SimplePrint(action Action, fn, absFn string)

func Slog

func Slog(action Action, fn, absFn string)

func TryExpand

func TryExpand(filename string) (string, error)

Types

type Action

type Action string

type Buffer

type Buffer struct {
	// contains filtered or unexported fields
}

func NewBuffer

func NewBuffer(opts *BufferOptions) *Buffer

func (*Buffer) Bytes

func (b *Buffer) Bytes() []byte

func (*Buffer) Clear

func (b *Buffer) Clear()

func (*Buffer) F

func (b *Buffer) F(format string, a ...any) Writer

func (*Buffer) FL

func (b *Buffer) FL(format string, a ...any) Writer

func (*Buffer) Filename

func (b *Buffer) Filename() string

func (*Buffer) I

func (b *Buffer) I(n int) Writer

func (*Buffer) If

func (b *Buffer) If(cond bool, s string) Writer

func (*Buffer) IfElse

func (b *Buffer) IfElse(cond bool, s, els string) Writer

func (*Buffer) IfElseFunc

func (b *Buffer) IfElseFunc(cond bool, f, els func()) Writer

func (*Buffer) IfFunc

func (b *Buffer) IfFunc(cond bool, f func()) Writer

func (*Buffer) IsEmpty

func (b *Buffer) IsEmpty() bool

func (*Buffer) Join

func (b *Buffer) Join(l []string, sep, lastSep string) Writer

func (*Buffer) JoinPairs

func (b *Buffer) JoinPairs(pairs []Pair, space, sep, lastSep string) Writer

func (*Buffer) L

func (b *Buffer) L(s string) Writer

func (*Buffer) Len

func (b *Buffer) Len() int

func (*Buffer) Modify

func (b *Buffer) Modify(f func(s string) string) Writer

func (*Buffer) NL

func (b *Buffer) NL() Writer

func (*Buffer) Overwrite

func (b *Buffer) Overwrite() bool

func (*Buffer) P

func (b *Buffer) P(s string) Writer

func (*Buffer) Perm

func (b *Buffer) Perm() fs.FileMode

func (*Buffer) Repeat

func (b *Buffer) Repeat(s string, n int) Writer

func (*Buffer) Save

func (b *Buffer) Save(root string, mkdirs bool, logger func(action Action, fn, absFn string)) error

func (*Buffer) SetFilename

func (b *Buffer) SetFilename(filename string) Writer

func (*Buffer) SetOverwrite

func (b *Buffer) SetOverwrite(overwrite bool) Writer

func (*Buffer) SetPerm

func (b *Buffer) SetPerm(perm fs.FileMode) Writer

func (*Buffer) String

func (b *Buffer) String() string

func (*Buffer) T

func (b *Buffer) T(template string, data any) Writer

func (*Buffer) TL

func (b *Buffer) TL(template string, data any) Writer

func (*Buffer) UsePlaceholder

func (b *Buffer) UsePlaceholder(name string, f func(p *Placeholder)) Writer

func (*Buffer) WritePlaceholder

func (b *Buffer) WritePlaceholder(p *Placeholder) Writer

type BufferOptions

type BufferOptions struct {
	Newline string
	Indent  string
}

type Buffers

type Buffers struct {
	// contains filtered or unexported fields
}

func NewBuffers

func NewBuffers() *Buffers

func (*Buffers) Add

func (bs *Buffers) Add(filename string, f func(w Writer)) *Buffer

func (*Buffers) Append

func (bs *Buffers) Append(filename string) *Buffer

func (*Buffers) Data

func (bs *Buffers) Data(filename string) string

func (*Buffers) Dump

func (bs *Buffers) Dump(out io.Writer)

func (*Buffers) Filenames

func (bs *Buffers) Filenames() []string

func (*Buffers) Find

func (bs *Buffers) Find(pattern string) []*Buffer

func (*Buffers) Get

func (bs *Buffers) Get(filename string) *Buffer

func (*Buffers) Has

func (bs *Buffers) Has(filename string) bool

func (*Buffers) Open

func (bs *Buffers) Open(filename string) *Buffer

func (*Buffers) Put

func (bs *Buffers) Put(filename string, f func(w Writer)) *Buffer

func (*Buffers) Save

func (bs *Buffers) Save(root string, logger func(action Action, fn, absFn string)) error

func (*Buffers) String

func (bs *Buffers) String() string

type Pair

type Pair struct {
	F, S string
}

type Placeholder

type Placeholder struct {
	Name   string
	Data   any
	Expand func(w Writer, data any)
	// contains filtered or unexported fields
}

type Writer

type Writer interface {
	Len() int
	IsEmpty() bool
	Filename() string
	SetFilename(filename string) Writer
	Perm() fs.FileMode
	SetPerm(perm fs.FileMode) Writer
	Overwrite() bool
	SetOverwrite(b bool) Writer
	Modify(func(s string) string) Writer
	WritePlaceholder(p *Placeholder) Writer
	UsePlaceholder(name string, f func(p *Placeholder)) Writer
	P(s string) Writer
	F(format string, a ...any) Writer
	T(template string, data any) Writer
	L(s string) Writer
	FL(format string, a ...any) Writer
	TL(template string, data any) Writer
	NL() Writer
	I(n int) Writer
	Repeat(s string, n int) Writer
	If(cond bool, s string) Writer
	IfFunc(cond bool, f func()) Writer
	IfElse(cond bool, s, els string) Writer
	IfElseFunc(cond bool, f, els func()) Writer
	Join(l []string, sep, lastSep string) Writer
	JoinPairs(pairs []Pair, space, sep, lastSep string) Writer
}

Directories

Path Synopsis
Package sdgengo 用于go代码生成
Package sdgengo 用于go代码生成

Jump to

Keyboard shortcuts

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