Viper go setup
Skill a5c-ai/babysitter/library/specializations/cli-mcp-development/skills/viper-go-setup
Set up Viper for Go configuration management with file, env, and flag binding.From its SKILL.md
npx -y skills add a5c-ai/babysitter --skill viper-go-setupAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
SKILL.md
1.6 KB, 274 tokens by cl100k_base, as published. Nobody here has run it
Viper Go Setup
Set up Viper for Go configuration management.
Generated Patterns
package 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
}
Target Processes
- configuration-management-system
- cli-application-bootstrap
What ships with it: 1 file
372 B alongside SKILL.md
- README.md372 B