Prompt
Carefully manage configuration options, including feature flags, to balance flexibility with maintainability:
- Use feature flags strategically:
- Put new features behind feature flags for gradual rollout
- Once fully deployed, remove the flag and make the feature standard
- Avoid feature flags when default behavior naturally preserves backward compatibility
// Good: Feature flag for gradual rollout
if featuremgmt.AnyEnabled(&featuremgmt.FeatureManager{}, featuremgmt.FlagNewFeature) {
providers = []app.Provider{playlistAppProvider, shortURLAppProvider}
} else {
providers = []app.Provider{playlistAppProvider}
}
// Better when possible: Backward compatible default behavior
options := getCookieOptions()
if featuremgmt.AnyEnabled(&featuremgmt.FeatureManager{}, featuremgmt.FlagPanelExporterCookieDomain) {
// Only modify behavior when flag is enabled
} else {
options.Domain = "" // Maintains previous behavior
}
- Limit configuration points:
- Start with fewer configuration options and add more only when needed
- Remember that once a configuration option is exposed, removing it may break user workflows
- Consider using appropriate metadata for feature flags (like
HideFromDocs: truefor internal features)
- Reuse existing configuration parsers rather than creating new ones to ensure consistent behavior across the application.