Skip to content

Commit

Permalink
add miss comment for pkg/cfg
Browse files Browse the repository at this point in the history
  • Loading branch information
alimy committed Nov 17, 2022
1 parent bace5bf commit 9f2ea40
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
3 changes: 2 additions & 1 deletion pkg/cfg/cfg.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package cfg

var (
_features = emptyFeatures()
_features = newEmptyFeatures()

// Use alias of Features.Use func
Use = _features.Use
Expand All @@ -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)
{
Expand Down
6 changes: 5 additions & 1 deletion pkg/cfg/feature.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand All @@ -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)
Expand Down

0 comments on commit 9f2ea40

Please sign in to comment.