Documentation
¶
Overview ¶
Package genx provides writers for generating code.
Note: Performs best unplugged. In New York.
Index ¶
- func AddLicense(paths []string) error
- func Cached(inputGlobs []string, outputs []string, generator func() error) error
- func FormatGo(paths []string) error
- func GitCommonDir(sourceRoot string) (string, error)
- func Go(path string) io.WriteCloser
- func Log() func()
- func Mode(mode os.FileMode) writerOpt
- func Prettier(paths []string) error
- func PrettyWriter(path string) io.WriteCloser
- func SourceRoot() (string, error)
- func Writer(path string, opts ...writerOpt) io.WriteCloser
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddLicense ¶
AddLicense adds a license to the given paths.
func Cached ¶
Cached invokes generator, a function that produces outputs from inputGlobs, but only if the inputs and outputs have changed since the last invocation.
func GitCommonDir ¶
GitCommonDir returns the common git directory for the repository at sourceRoot. This handles git worktrees where .git is a file instead of a directory.
func Log ¶
func Log() func()
Log emits a log message that memorializes the start of the code generation process, returning a function that, when called, will log the completion time of the generation.
Use it like:
func main() {
defer genx.Log()()
// ...
}
func PrettyWriter ¶
func PrettyWriter(path string) io.WriteCloser
PrettyWriter is a writer than passes the contents through prettier before writing them to disk.
func SourceRoot ¶
SourceRoot returns the source root directory by looking for .git
func Writer ¶
func Writer(path string, opts ...writerOpt) io.WriteCloser
Writer returns an io.WriteCloser that writes to the given path, but only if the contents are different from the current contents.
Types ¶
This section is empty.