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,746 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
48 /100 Fair
Development Activity 0
Maintenance 20
Community 72
Maturity 60
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
71 /100 Good
Architecture 70
Code Quality 78
Innovation 55
Learning Curve 80

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 15 apps in this directory

Go
85%
Apache 2.0

Argo Workflows

Data Engineering · Devops

17,029

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

View details
96
Repo Health
90
Technical
68
Dependency
Built with
Go 85%
TypeScript 11%
Updated yesterday
Go
56%
Apache 2.0

Authgear

Authentication

2,102

Open-source, self-hostable authentication platform with passkeys, biometric login, SSO, MFA, and GraphQL admin API — a full Auth0/Clerk/Firebase alternative for SaaS and mobile apps.

View details
89
Repo Health
81
Technical
68
Dependency
Built with
Go 56%
HTML 24%
TypeScript 18%
Updated yesterday
Go
98%
Apache 2.0

Caddy

Devops · Security

77,653

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
93
Repo Health
86
Technical
74
Dependency
Built with
Go 98%
Updated yesterday
TypeScript
48%
AGPL 3.0

Grafana

Analytics · Monitoring

77,212

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
63
Dependency
Built with
TypeScript 48%
Go 47%
Updated today
Go
97%
Apache 2.0

infracost

Developer Tools · Devops

12,560

Infracost shows cloud cost estimates for Terraform, CloudFormation, and AWS CDK before you deploy — in your terminal, editor, AI coding agent, and pull requests.

View details
82
Repo Health
78
Technical
67
Dependency
Built with
Go 97%
Updated yesterday
Go
42%
AGPL 3.0

listmonk

Blogging · Marketing

23,727

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
81
Repo Health
74
Technical
67
Dependency
Built with
Go 42%
Vue 24%
JavaScript 19%
Updated 3 days ago
Go
47%
GPL 3.0

Netdata

Devops · Monitoring

80,863

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

View details
93
Repo Health
86
Technical
70
Dependency
Built with
Go 47%
C 29%
Rust 15%
Updated today
Go
91%
Apache 2.0

Ory Kratos

Authentication

13,913

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

View details
79
Repo Health
78
Technical
65
Dependency
Built with
Go 91%
Updated 2 months ago
Go
39%
Apache 2.0

Rill

Analytics · Data Engineering

2,936

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
88
Repo Health
88
Technical
64
Dependency
Built with
Go 39%
TypeScript 38%
Svelte 21%
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