refactor to use maps.Clone

pull/4942/head
cuiweixie 2025-08-17 21:00:15 +08:00
parent 14253afe2f
commit 51eb7da871
1 changed files with 2 additions and 5 deletions

View File

@ -16,6 +16,7 @@ package featuregate
import ( import (
"fmt" "fmt"
"maps"
"sort" "sort"
"strings" "strings"
"sync" "sync"
@ -92,11 +93,7 @@ type featureGate struct {
// NewFeatureGate creates a new feature gate with the default features // NewFeatureGate creates a new feature gate with the default features
func NewFeatureGate() MutableFeatureGate { func NewFeatureGate() MutableFeatureGate {
known := map[Feature]FeatureSpec{} known := maps.Clone(defaultFeatures)
for k, v := range defaultFeatures {
known[k] = v
}
f := &featureGate{} f := &featureGate{}
f.known.Store(known) f.known.Store(known)
f.enabled.Store(map[Feature]bool{}) f.enabled.Store(map[Feature]bool{})