mirror of
https://gitee.com/johng/gf
synced 2026-06-06 02:25:47 +08:00
improve package gcmd/gtag
This commit is contained in:
@ -57,6 +57,9 @@ func NewFromObject(object interface{}) (rootCmd *Command, err error) {
|
||||
rootCommandName = gmeta.Get(object, tagNameRoot).String()
|
||||
subCommands []*Command
|
||||
)
|
||||
if rootCommandName == "" {
|
||||
rootCommandName = rootCmd.Name
|
||||
}
|
||||
for i := 0; i < originValueAndKind.InputValue.NumMethod(); i++ {
|
||||
var (
|
||||
method = originValueAndKind.InputValue.Method(i)
|
||||
|
||||
@ -10,6 +10,7 @@
|
||||
package gtag
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"regexp"
|
||||
"sync"
|
||||
)
|
||||
@ -24,6 +25,9 @@ var (
|
||||
func Set(name, value string) {
|
||||
mu.Lock()
|
||||
defer mu.Unlock()
|
||||
if _, ok := data[name]; ok {
|
||||
panic(fmt.Sprintf(`value for tag "%s" already exists`, name))
|
||||
}
|
||||
data[name] = value
|
||||
}
|
||||
|
||||
@ -32,6 +36,9 @@ func Sets(m map[string]string) {
|
||||
mu.Lock()
|
||||
defer mu.Unlock()
|
||||
for k, v := range m {
|
||||
if _, ok := data[k]; ok {
|
||||
panic(fmt.Sprintf(`value for tag "%s" already exists`, k))
|
||||
}
|
||||
data[k] = v
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user