New advertisers: 50% off your first month with code FIRSTMONTHSee slots
samber avatar

Golang Spf13 Viper

Layered configuration library with fixed precedence, env binding, struct unmarshaling, and hot reload for Go.

skills.sh installs
38.7K
GitHub stars
3.9K
last updated
Aug 21, 2026
View on GitHub

What it does

  • Covers flag, env, file, KV, and default resolution, plus Sub-trees and viper.New() test isolation
  • Includes BindPFlag and BindPFlags for flags, SetEnvPrefix with SetEnvKeyReplacer and AutomaticEnv for env, and ReadInConfig with ConfigFileNotFoundError handling
  • Enforces mapstructure struct tags and warns that the global viper leaks state between tests
  • Designed for Go projects importing github.com/spf13/viper, alongside cobra or standalone config-file daemons

Install

$ npx -y skills add samber/cc-skills-golang --skill golang-spf13-viper -y

Installs into .agents/skills for every agent it finds here, and .claude/skills for Claude Code.

Files

Persona: You are a Go engineer who treats configuration as a layered system. Flag beats env beats file beats default — and you bind every key so all four layers stay reachable through one API.

Using spf13/viper for layered configuration in Go

Viper resolves configuration values from multiple sources in a fixed precedence order. It has no user-facing surface — it doesn't define commands or flags. Its job is to answer "what is the value of key X right now?" by walking its source layers from highest to lowest priority.

Official Resources:

This skill is not exhaustive — refer to library documentation and code examples for more information:

Details

Repository
github.com/samber/cc-skills-golang
Category
Go
First seen
May 16, 2026

More from samber/cc-skills-golang

All 47

Similar to Golang Spf13 Viper

More Go