Documentation Index
Fetch the complete documentation index at: https://docs-mstore.faisalaffan.com/llms.txt
Use this file to discover all available pages before exploring further.
Configuration & Secrets
Panduan mengelola configuration dan secrets menggunakan Viper dan environment variables.
⚙️ Configuration Management
Using Viper
type Config struct {
Server ServerConfig
Database DatabaseConfig
JWT JWTConfig
}
type ServerConfig struct {
Port string `mapstructure:"port"`
Env string `mapstructure:"env"`
}
func LoadConfig() (*Config, error) {
viper.SetConfigName("config")
viper.SetConfigType("yaml")
viper.AddConfigPath("./configs")
viper.AutomaticEnv()
if err := viper.ReadInConfig(); err != nil {
return nil, err
}
var config Config
if err := viper.Unmarshal(&config); err != nil {
return nil, err
}
return &config, nil
}
Config File (YAML)
server:
port: 8080
env: development
database:
host: ${DB_HOST}
port: ${DB_PORT}
user: ${DB_USER}
password: ${DB_PASSWORD}
name: ${DB_NAME}
jwt:
secret: ${JWT_SECRET}
expiry: 24h
🔐 Secrets Management
Environment Variables
# .env
DB_HOST=localhost
DB_PORT=3306
DB_USER=root
DB_PASSWORD=secret
DB_NAME=windsurf_db
JWT_SECRET=your-super-secret-key
Best Practices
- ✅ Never commit
.env to git
- ✅ Use
.env.example as template
- ✅ Rotate secrets regularly
- ✅ Use different secrets per environment
- ✅ Use secret management tools (Vault, AWS Secrets Manager)
Local Setup
Environment setup
DevOps
Deployment workflow