Help us shape the future of Go! Take the 2026 Go Developer Survey

render

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package render turns templates into the config files bothy launches its tools against. Everything it writes goes inside bothy's own tree (ADR-009).

Two rules:

  • Every generated file says it is generated, and names where to put your own changes.
  • Overrides are appended after the template, so your setting wins.

Index

Constants

View Source
const HeaderLines = 5

HeaderLines is how far into a file the marker may appear.

View Source
const Marker = "generated by bothy"

Marker identifies a bothy-generated file. It appears inside a comment whose syntax varies by file type, so detection looks for the marker in the first few lines rather than for an exact prefix.

Variables

This section is empty.

Functions

func Header(dest, tool string) string

Header returns the banner for a destination path, in that file type's comment syntax.

func IsGenerated

func IsGenerated(path string) bool

IsGenerated reports whether a file carries bothy's header.

Types

type Writer

type Writer struct {
	// Root is bothy's tree — config/ and bin/ both live under it. Write
	// refuses any destination outside it.
	Root string
	// Overrides is ~/.config/bothy/overrides.
	Overrides string
	// DryRun reports what would happen without touching the filesystem.
	DryRun bool
}

Writer renders templates into bothy's tree.

func NewWriter

func NewWriter(root, overrides string) *Writer

NewWriter constructs a Writer for one install run.

func (*Writer) Render

func (w *Writer) Render(dest, tool, tmplName, tmplText string, data any) ([]byte, error)

Render executes a template and returns the bytes to write, header and overrides included. tool names the override subdirectory.

func (*Writer) Write

func (w *Writer) Write(dest string, content []byte) (changed bool, err error)

Write puts content at dest, which must be inside Root. It reports whether the file changed, so an install can say how much of it was already current.

func (*Writer) WriteExec

func (w *Writer) WriteExec(dest string, content []byte) (bool, error)

WriteExec writes an executable file.

Jump to

Keyboard shortcuts

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