Sprig
Over 100 template functions for Go's text/template and html/template, covering strings, lists, dicts, dates, math, crypto, and semver comparisons.
Repository Health
Technical Analysis
Sprig is a Go library that extends the standard library’s text/template and html/template packages with more than 100 utility functions. Go’s built-in templating language is deliberately minimal, so Sprig fills the gap with string manipulation, list and dict helpers, date formatting, type conversion, math, cryptographic hashing, regular expressions, URL parsing, and semantic version comparison, all callable directly from template pipelines.
The project is widely used as a dependency inside other tools rather than a standalone application: Helm (the Kubernetes package manager) bundles Sprig to power chart templating, and it shows up throughout the Go templating ecosystem wherever text/template needs more expressive power. It is distributed as a single importable package with no external services or configuration required.
Sprig follows a deliberate design philosophy: template functions should never return hard errors when a sensible default can be produced instead, arguments are frequently ordered to support piping ({{ "foo" | repeat 5 }}), and functions are kept purely presentational rather than allowed to fetch or mutate external data. The library ships two major, source-compatible-but-behaviorally-different version lines (v2 and v3), with v3 as the actively maintained release on the module path github.com/Masterminds/sprig/v3.
What You Get
- A single
sprig.FuncMap()call that registers 100+ functions on anytext/templateorhtml/templateinstance - String helpers (trim, truncate, case conversion, base64/base32, quoting, wrapping) inspired by Twig and underscore.js
- List and dict helpers (push, prepend, uniq, without, merge, pluck, dict manipulation) using reflection so they work across slice and map types
- Date formatting and manipulation functions, plus math, type-conversion, and default-value helpers for safe fallbacks
- Cryptographic helpers (SHA, bcrypt, derivePassword, genPrivateKey) and URL/regex utilities for common templating chores
- Semver comparison functions built on
Masterminds/semverfor version-gated template logic - A
HermeticTxtFuncMap/HermeticHtmlFuncMapvariant that strips non-deterministic functions (likenoworrandAlphaNum) for reproducible rendering
Common Use Cases
- Kubernetes/Helm chart templating, where Sprig is the built-in function set for chart authors
- Generating configuration files, boilerplate code, or infrastructure manifests from Go templates
- Building internal CLI or codegen tools that render text/HTML from user-supplied or static templates
- Adding safe default values and type coercion to templates fed by loosely-typed data (YAML/JSON configs)
- Comparing semantic versions inside templates to gate feature output by version constraints
Under The Hood
Architecture
Sprig is organized as a flat, single-package library with functions grouped by domain into separate files (strings.go, list.go, dict.go, date.go, crypto.go, numeric.go, regex.go, url.go, semver.go, reflect.go, network.go, defaults.go). A central functions.go assembles every domain’s exports into one genericMap, exposed through FuncMap()/TxtFuncMap()/HtmlFuncMap() and hermetic variants that filter out non-deterministic entries like now and random generators via a nonhermeticFunctions list. There is no layering beyond this registry pattern — each function is a small, self-contained transform with no shared internal state, which keeps the blast radius of any single function change limited to its own file.
Tech Stack
The module targets modern Go (go.mod requires go 1.23 with a 1.24 toolchain) and pulls in a small set of focused dependencies: dario.cat/mergo for map merging, Masterminds/goutils and huandu/xstrings for string helpers, Masterminds/semver/v3 for version comparison, google/uuid for identifiers, mitchellh/copystructure for deep copies, shopspring/decimal for precise arithmetic, spf13/cast for type coercion, and golang.org/x/crypto for hashing/bcrypt. There is no build tooling beyond go build/go test; a Makefile wraps common commands and GitHub Actions runs the test suite on push.
Code Quality
Every domain file has a matching _test.go file (crypto, date, dict, list, network, numeric, regex, semver, strings, url, reflect, defaults, flow_control), and tests exercise functions through actual template execution via a runt() helper rather than only unit-testing raw Go calls, which validates the piping behavior end to end. testify/assert is used for assertions. Error handling favors returning zero-value/default output over propagating errors, consistent with the project’s stated design principle that template functions shouldn’t break rendering. No linter config or static-analysis tooling is checked in beyond go vet implied by CI.
What Makes It Unique Sprig’s contribution isn’t a novel algorithm but a deliberate, well-documented set of conventions for template-function ergonomics: reversed argument order to support piping, refusal to hit external error paths where a default will do, and a hard rule against functions that fetch external data or override core template behavior. Its main technical distinction is being the de facto function set behind Helm’s chart templating, which has made its API surface and defaults an implicit standard across the Go templating ecosystem rather than one library among many.
Used by 12 apps in this directory
Argo Workflows
Devops · Data Engineering
The most popular Kubernetes-native workflow engine for orchestrating containerized DAGs, ML pipelines, CI/CD, and parallel batch jobs at scale.
Caddy
Devops · Security
The only web server that obtains and renews TLS certificates automatically, with HTTP/1-2-3 support and zero dependency on external runtimes.
Grafana
Monitoring · Analytics
The open-source observability platform that unifies metrics, logs, and traces from any data source into dynamic, queryable dashboards.
listmonk
Marketing · Blogging
High-performance, self-hosted newsletter and mailing list manager packaged as a single binary with built-in analytics, transactional messaging, and multi-channel delivery.
Netdata
Monitoring · Devops
Real-time per-second metrics, ML-powered anomaly detection, and zero-config observability for any infrastructure.
Ory Kratos
Authentication
API-first identity and user management that handles login, registration, MFA, and recovery so your application never has to.
Rill
Analytics · Data Engineering
The fastest BI tool for humans and agents — define metrics, models, and dashboards as code and query them instantly on ClickHouse or DuckDB.
Teleport
Security · Authentication
Zero-trust infrastructure access platform that replaces credentials and VPNs with short-lived certificates, SSO, and identity-aware proxies for SSH, Kubernetes, databases, RDP, and AI agents.
temporal
Automation · Devops
Open-source durable execution platform that keeps mission-critical workflows running through any failure, automatically.