genx

package
v0.1.19 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package genx provides writers for generating code.

Note: Performs best unplugged. In New York.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddLicense

func AddLicense(paths []string) error

AddLicense adds a license to the given paths.

func Cached

func Cached(
	inputGlobs []string,
	outputs []string,
	generator func() error,
) error

Cached invokes generator, a function that produces outputs from inputGlobs, but only if the inputs and outputs have changed since the last invocation.

func FormatGo

func FormatGo(paths []string) error

FormatGo formats go source code according to our rules

func GitCommonDir

func GitCommonDir(sourceRoot string) (string, error)

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 Go

func Go(path string) io.WriteCloser

Go returns a writer for formatted Go code.

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 Mode

func Mode(mode os.FileMode) writerOpt

Mode sets the file mode of the file to something other than the default (0644)

func Prettier

func Prettier(paths []string) error

Prettier runs prettier on the given paths.

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

func SourceRoot() (string, error)

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.

Jump to

Keyboard shortcuts

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