Sprig

Over 100 template functions for Go's text/template and html/template, covering strings, lists, dicts, dates, math, crypto, and semver comparisons.

Library
Go
vv3.3.0
4,737stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
48/100Fair
Development Activity0
Maintenance20
Community72
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
71/100Good
Architecture70
Code Quality78
Innovation55
Learning Curve80

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 any text/template or html/template instance
  • 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/semver for version-gated template logic
  • A HermeticTxtFuncMap/HermeticHtmlFuncMap variant that strips non-deterministic functions (like now or randAlphaNum) 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

Go
85%
Apache 2.0

Argo Workflows

Devops · Data Engineering

16,943

The most popular Kubernetes-native workflow engine for orchestrating containerized DAGs, ML pipelines, CI/CD, and parallel batch jobs at scale.

View details
95
Repo Health
90
Technical
68
Dependency
Built with
Go85%
TypeScript11%
Updated yesterday
Go
98%
Apache 2.0

Caddy

Devops · Security

75,334

The only web server that obtains and renews TLS certificates automatically, with HTTP/1-2-3 support and zero dependency on external runtimes.

View details
92
Repo Health
86
Technical
76
Dependency
Built with
Go98%
Updated 2 days ago
TypeScript
49%
AGPL 3.0

Grafana

Monitoring · Analytics

76,498

The open-source observability platform that unifies metrics, logs, and traces from any data source into dynamic, queryable dashboards.

View details
95
Repo Health
91
Technical
65
Dependency
Built with
TypeScript49%
Go45%
Updated today
Go
41%
AGPL 3.0

listmonk

Marketing · Blogging

23,177

High-performance, self-hosted newsletter and mailing list manager packaged as a single binary with built-in analytics, transactional messaging, and multi-channel delivery.

View details
86
Repo Health
74
Technical
68
Dependency
Built with
Go41%
Vue24%
JavaScript19%
Updated 5 days ago
Go
44%
GPL 3.0

Netdata

Monitoring · Devops

80,357

Real-time per-second metrics, ML-powered anomaly detection, and zero-config observability for any infrastructure.

View details
93
Repo Health
86
Technical
71
Dependency
Built with
Go44%
C32%
Rust15%
Updated today
Go
91%
Apache 2.0

Ory Kratos

Authentication

13,853

API-first identity and user management that handles login, registration, MFA, and recovery so your application never has to.

View details
84
Repo Health
78
Technical
67
Dependency
Built with
Go91%
Updated 1 months ago
Go
39%
Apache 2.0

Rill

Analytics · Data Engineering

2,853

The fastest BI tool for humans and agents — define metrics, models, and dashboards as code and query them instantly on ClickHouse or DuckDB.

View details
87
Repo Health
88
Technical
66
Dependency
Built with
Go39%
TypeScript37%
Svelte22%
Updated 2 days ago
Go
75%
AGPL 3.0

Teleport

Security · Authentication

20,860

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.

View details
94
Repo Health
81
Technical
69
Dependency
Built with
Go75%
TypeScript16%
Updated 2 days ago
Go
99%
MIT

temporal

Automation · Devops

22,602

Open-source durable execution platform that keeps mission-critical workflows running through any failure, automatically.

View details
92
Repo Health
85
Technical
69
Dependency
Built with
Go99%
Updated today

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search