From 9f2ea407f8c7818f7af790b1f1df95973ab8cfe2 Mon Sep 17 00:00:00 2001 From: Michael Li Date: Thu, 17 Nov 2022 17:34:17 +0800 Subject: [PATCH] add miss comment for pkg/cfg --- pkg/cfg/cfg.go | 3 ++- pkg/cfg/feature.go | 6 +++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/pkg/cfg/cfg.go b/pkg/cfg/cfg.go index e0a94ef3..019deba9 100644 --- a/pkg/cfg/cfg.go +++ b/pkg/cfg/cfg.go @@ -1,7 +1,7 @@ package cfg var ( - _features = emptyFeatures() + _features = newEmptyFeatures() // Use alias of Features.Use func Use = _features.Use @@ -25,6 +25,7 @@ var ( Not = _features.CfgNot ) +// Initialize initialize features in cfg pkg func Initialize(suites map[string][]string, kv map[string]string) { _features = NewFeatures(suites, kv) { diff --git a/pkg/cfg/feature.go b/pkg/cfg/feature.go index f407b3a2..4fec8737 100644 --- a/pkg/cfg/feature.go +++ b/pkg/cfg/feature.go @@ -6,6 +6,7 @@ import ( "github.com/rocboss/paopao-ce/pkg/types" ) +// Features fetures info struct type Features struct { kv map[string]string suites map[string][]string @@ -15,6 +16,7 @@ type Features struct { // Actions feature-func map alias type type Actions map[string]types.Fn +// NewFeatures create new Features instance func NewFeatures(suites map[string][]string, kv map[string]string) *Features { f := &Features{ suites: suites, @@ -25,16 +27,18 @@ func NewFeatures(suites map[string][]string, kv map[string]string) *Features { return f } -func emptyFeatures() *Features { +func newEmptyFeatures() *Features { return &Features{ features: make(map[string]string), } } +// UseDefault use default suite for features func (f *Features) UseDefault() { f.Use([]string{"default"}, true) } +// Use use custom suite for features func (f *Features) Use(suite []string, noDefault bool) error { if noDefault && len(f.features) != 0 { f.features = make(map[string]string)