Documentation
¶
Index ¶
- func Add(a, b int) int
- func AddImportRegex(regex string, path string, alias string) error
- func Div(a, b int) int
- func Mul(a, b int) int
- func Render(options *Options) error
- func Sub(a, b int) int
- func UserCodeEnd(action string) string
- func UserCodeSection() string
- func UserCodeStart(action string) string
- type Import
- type Options
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddImportRegex ¶
AddImportRegex add a new import regex and path to the importRegexMap it will auto import the package in the template if alias is not empty, it will use the alias as the import alias like import command "github.com/light-speak/lighthouse/command"
func UserCodeEnd ¶
func UserCodeSection ¶
func UserCodeSection() string
func UserCodeStart ¶
Types ¶
type Options ¶
type Options struct {
// Path is the path to the file
// for example, if the Path is "cmd/cli/generate/cmd", the file will be created in the "cmd/cli/generate/cmd" directory
Path string
Template string
FileName string
// if Package is not empty, the package name will be added to the file
// for example, if the Package is "main", the package name will be "package main"
// if the Package is "", it will automatically get the package name from the path
Package string
Data any
// The editable notice will be like:
// # Code generated by github.com/light-speak/lighthouse, YOU CAN FUCKING EDIT BY YOURSELF.
// otherwise, it will add the non-editable notice to the file
// The non-editable notice will be like:
// # Code generated by github.com/light-speak/lighthouse, DO NOT EDIT.
Editable bool
// if FileExt is not empty, the file will be created with the file extension
// for example, if the FileExt is "go", the file will be created with the .go extension
// if the FileExt is "", the file will be created without any extension
FileExt string
// if SkipIfExists is true, the file will not be created if the file already exists
// otherwise, the file will be merged with the user code sections
// the user code sections defined in the template with the comment:
// # Func:xxx user code start / end. Do not remove this comment.
// # Section: user code section start / end. Do not remove this comment.
SkipIfExists bool
// if SkipImport is true, the import section will not be added to the file
SkipImport bool
Imports []*Import
Funcs template.FuncMap
}
Click to show internal directories.
Click to hide internal directories.