conflate

package
v0.0.12 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2026 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Overview

Package conflate provides general-purpose string parsing, transformation, and template merging. It extracts named capture groups from a regexp, applies caller-supplied transforms, and merges the results into a text/template.

The three functions — Parse, Transform, Merge — are independently useful and designed to be composed by the caller.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Merge

func Merge(format string, data map[string]string) (string, error)

Merge compiles format into a template and then calls MergeTemplate with it and data.

func MergeTemplate

func MergeTemplate(tmpl *template.Template, data map[string]string) (string, error)

MergeTemplate executes tmpl against data and returns the result string.

func Parse

func Parse(pattern, input string) (map[string]string, error)

Parse compiles pattern into a regular expression and then calls ParseRegexp with it and input.

func ParseRegexp

func ParseRegexp(exp *regexp.Regexp, input string) (map[string]string, error)

ParseRegexp extracts named capture groups from input using exp. Returns raw (untransformed) string values keyed by group name. An error is returned if input does not match exp.

func Transform

func Transform(groups map[string]string, transformers map[string]TransformFunc) (map[string]string, error)

Transform applies transformers to matching keys in groups. Keys without a matching transformer pass through unchanged. Returns a new map; does not mutate the input.

Types

type TransformFunc

type TransformFunc func(value string) (string, error)

TransformFunc converts a single captured field value.

Jump to

Keyboard shortcuts

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