1 Star 1 Fork 1

xiaoyutab/xgotool

Create your Gitee Account
Explore and code with more than 12 million developers,Free private repositories !:)
Sign up
Clone or Download
push.go 831 Bytes
Copy Edit Raw Blame History
xiaoyutab authored 2024-01-17 15:24 . 代码优化
package xconsole
import "errors"
// 推送任务到路由接口中
//
// rou 执行的命令
// fun 执行的命令内容
func Push(rou string, fun Command) error {
if _, ok := _default.r[rou]; ok {
return errors.New("命令 " + rou + " 已存在")
}
_default.Lock()
defer _default.Unlock()
_default.r[rou] = fun
return nil
}
// 要移除的命令列表
func UnPush(rou []string) error {
_default.Lock()
defer _default.Unlock()
for i := 0; i < len(rou); i++ {
delete(_default.r, rou[i])
}
return nil
}
// 批量推送任务到路由接口中
//
// m map结构的任务键值对
func PushMap(m map[string]Command) error {
_default.Lock()
defer _default.Unlock()
for k, v := range m {
if _, ok := _default.r[k]; ok {
return errors.New("命令 " + k + " 已存在")
}
_default.r[k] = v
}
return nil
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/xiaoyutab/xgotool.git
git@gitee.com:xiaoyutab/xgotool.git
xiaoyutab
xgotool
xgotool
v0.3.34

Search