tmpl

package
v0.0.0-...-8a7fe10 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Filename string `yaml:"filename"`       // 生成的文件名
	Template string `yaml:"tmpl,omitempty"` // 用于渲染的 go 模板文件路径

	Open bool   `yaml:"open"`          // 文件生成后,是否自动打开该文件
	App  string `yaml:"app,omitempty"` // Open 字段为 true 时才可用,使用指定软件打开文件,通常是 GoLand 或 VSCode 的安装位置,如果为空则使用系统默认软件打开
}

type Data

type Data struct {
	// for code snippet
	Solution

	// for unit test
	UnitTest

	Data *api.QuestionData
}

Data 用于渲染模板文件的数据

func NewData

func NewData(data *api.QuestionData) Data

type Sample

type Sample struct {
	Input  []string
	Output []string
}

type Samples

type Samples []Sample

func NewSamples

func NewSamples(q *api.QuestionData) Samples

func (Samples) String

func (s Samples) String() (samples string)

type Solution

type Solution struct {
	Code           string // 模板代码
	NeedMod        bool   // 是否需要取模
	NeedDefinition bool   // 是否需要取模
}

func NewSolution

func NewSolution(q *api.QuestionData) Solution

type Template

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

func NewTemplate

func NewTemplate(config Config, data Data) *Template

func (*Template) Execute

func (t *Template) Execute(w io.Writer) (err error)

func (*Template) Save

func (t *Template) Save(root string) (err error)

type UnitTest

type UnitTest struct {
	RunType  string // Class or Func
	FuncName string
	FuncType string
	Samples  string
}

func NewUnitTest

func NewUnitTest(q *api.QuestionData) (data UnitTest)

Jump to

Keyboard shortcuts

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