template

package
v1.3.1 Latest Latest
Warning

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

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

Documentation

Overview

Package template builds the text/template instances used by the transformers that accept user provided templates. The greenmask toolkit function map they rely on closes over state that is not safe for concurrent use (a shared *rand.Rand behind randomInt/randomString/noiseInt/..., and a pgtype.Map behind tsModify/noiseDatePgInterval), so a single template cannot be executed by several snapshot workers at once. Templates are pooled instead: each execution gets an instance with function map state of its own.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Template

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

Template is a text/template with the greenmask toolkit and sprig function maps available to it, safe for concurrent execution.

func New

func New(name, text string) (*Template, error)

New parses text into a template named name. Parse errors are reported here rather than on first execution.

func (*Template) Execute

func (t *Template) Execute(w io.Writer, data any) error

Execute applies the template to data, writing the output to w. It can be called concurrently.

Jump to

Keyboard shortcuts

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