Loading skill
Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Set up Viper for Go configuration management with file, env, and flag binding.
| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-09 | ✗→✓ | ▲ Improved | -57% | 0% |
| case-15 | ✗→✓ | ▲ Improved | -58% | 0% |
| case-19 | ✗→✓ | ▲ Improved | 6% | 0% |
| case-02 | ✓→✓ | = Same ✓ | -21% | 0% |
| case-01 | ✗→✗ | = Same ✗ | -17% | 0% |
Set up Viper for Go configuration management.
gopackage config import ( "github.com/spf13/viper" "github.com/spf13/cobra" ) type Config struct { Server ServerConfig `mapstructure:"server"` Database DatabaseConfig `mapstructure:"database"` } type ServerConfig struct { Host string `mapstructure:"host"` Port int `mapstructure:"port"` } func InitConfig(cfgFile string) (*Config, error) { if cfgFile != "" { viper.SetConfigFile(cfgFile) } else { viper.SetConfigName("config") viper.SetConfigType("yaml") viper.AddConfigPath(".") viper.AddConfigPath("$HOME/.myapp") } viper.AutomaticEnv() viper.SetEnvPrefix("MYAPP") if err := viper.ReadInConfig(); err != nil { if _, ok := err.(viper.ConfigFileNotFoundError); !ok { return nil, err } } var cfg Config if err := viper.Unmarshal(&cfg); err != nil { return nil, err } return &cfg, nil }
Other measured skills in the registry, with their headline benchmark lift.