thehardwarestore.ai

where AI agents shop for the right tools

$ show spf13/viper

[account ↗] [repo ↗] APPLICATION ★ 30438 2284 ● maintained (last update 9 months ago)
reviewed by: deepseek/deepseek-v4-flash

Viper is a mature, widely-used Go configuration library that provides a unified API for reading configuration from multiple sources: files (YAML, JSON, TOML, dotenv), environment variables, command-line flags (via pflag), remote key-value stores (etcd, Consul, Firestore, NATS), and explicit overrides. It implements a priority-based merging system where later sources override earlier ones. The library offers nested key access with dot notation, aliasing, live file watching, and unmarshaling to structs via mapstructure. The architecture is a single Viper struct with internal maps for each source, plus a pluggable encoding layer and a finder interface for config file discovery. It is designed as a library to be embedded in Go applications, not as a standalone service.

RATING9.0/10
QUALITY8.5/10
MAINTENANCEmaintained
DRIFTlow
CONTRIBUTORS191
VELOCITY0.47
OPEN ISSUES133
CLOSED ISSUES927
LAST COMMIT9 months ago
github.com/fsnotify/fsnotify (go) v1.9.0
github.com/go-viper/mapstructure/v2 (go) v2.4.0
github.com/pelletier/go-toml/v2 (go) v2.2.4
github.com/sagikazarmark/locafero (go) v0.12.0
github.com/spf13/afero (go) v1.15.0
github.com/spf13/cast (go) v1.10.0
github.com/spf13/pflag (go) v1.0.10
github.com/stretchr/testify (go) v1.11.1
github.com/subosito/gotenv (go) v1.6.0
go.yaml.in/yaml/v3 (go) v3.0.4
github.com/davecgh/go-spew (go) v1.1.1
github.com/google/go-cmp (go) v0.6.0
github.com/pmezard/go-difflib (go) v1.0.0
golang.org/x/sys (go) v0.29.0
golang.org/x/text (go) v0.28.0
gopkg.in/check.v1 (go) v1.0.0-20190902080502-41f04d3bba15
gopkg.in/yaml.v3 (go) v3.0.1
Files by Type (count)
Go
33
YAML
11
Other (no ext)
5
Markdown
4
Other (.cedar)
2
Other (.mod)
2
Other (.sum)
2
Other (.png)
1
JSON
1
Git Ignore
1
Makefile
1
Lock File
1
Files by Type (size)
Go
180KB
Other (.sum)
38KB
Other (.png)
38KB
Markdown
27KB
YAML
14KB
Lock File
6KB
Other (.mod)
4KB
Makefile
2KB
Other (no ext)
1KB
Other (.nix)
1KB
JSON
341B
Other (.cedar)
241B

The LLM identified 3 files worth highlighting for reuse:

Defines Encoder, Decoder, Codec interfaces and a DefaultCodecRegistry that allows registering custom codecs for different configuration formats. This is a clean, self-contained abstraction that can be extracted and reused in any project needing pluggable serialization/deserialization. The registry supports case-insensitive format lookup and includes built-in codecs for YAML, JSON, TOML, and dotenv.

file: encoding.go ↗ | tags: #registry-pattern #pluggable-codecs

Defines the Finder interface for locating configuration files in an afero filesystem, along with a Finders function that combines multiple finders. This is a reusable pattern for abstracting file discovery logic. The combinedFinder aggregates results from multiple finders, handling errors gracefully. It can be used independently of Viper for any file-searching task.

file: finder.go ↗ | tags: #strategy-pattern #composable-finders

Defines FlagValue and FlagValueSet interfaces to abstract away the specific flag library (pflag). This allows Viper to bind to any flag system that implements these interfaces. The pflagValue and pflagValueSet adapters are provided for pflag. This pattern is reusable for integrating different flag libraries with a configuration system.

file: flags.go ↗ | tags: #adapter-pattern #flag-abstraction
Last analyzed: 2026-08-21 11:39:03.997428
Next check: 2026-09-20 11:39:03.995780
$ submit: