From cd3d57a6f726911ac03a4f9e99a8964e781369fb Mon Sep 17 00:00:00 2001 From: shaoying Date: Thu, 12 Aug 2021 08:47:05 +0800 Subject: [PATCH] opt golang --- base/web/cache.go | 2 +- core/code/go.go | 2 +- misc.go | 7 +++++++ misc/git/repos.go | 1 + 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/base/web/cache.go b/base/web/cache.go index 41e9683d..ac238550 100644 --- a/base/web/cache.go +++ b/base/web/cache.go @@ -19,7 +19,7 @@ func _cache_save(m *ice.Message, kind, name, text string, arg ...string) { // fi if name == "" { return } - if len(text) > 512 { // 存入文件 + if len(text) > 512 || kind == "go" { // 存入文件 p := m.Cmdx(nfs.SAVE, _cache_name(m, kit.Hashs(text)), text) text, arg = p, kit.Simple(p, len(text)) } diff --git a/core/code/go.go b/core/code/go.go index 01451e4c..33207909 100644 --- a/core/code/go.go +++ b/core/code/go.go @@ -200,7 +200,7 @@ func init() { "string", "byte", "bool", "error", "chan", "map", ), FUNCTION, kit.Simple( - "len", "cap", "copy", "append", "msg", "m", + "new", "make", "len", "cap", "copy", "append", "delete", "msg", "m", ), CONSTANT, kit.Simple( "false", "true", "nil", "-1", "0", "1", "2", diff --git a/misc.go b/misc.go index 39feb735..970979bc 100644 --- a/misc.go +++ b/misc.go @@ -316,6 +316,13 @@ func (c *Context) cmd(m *Message, cmd *Command, key string, arg ...string) *Mess return m } func (c *Context) _cmd(m *Message, cmd *Command, key string, k string, h *Action, arg ...string) *Message { + if k == "command" && h.Hand == nil { + for _, cmd := range arg { + m.Cmdy("command", cmd) + } + return m + } + if k == "run" && m.Warn(!m.Right(arg), ErrNotRight, arg) { return m } diff --git a/misc/git/repos.go b/misc/git/repos.go index 722bc1ef..7f2f59ea 100644 --- a/misc/git/repos.go +++ b/misc/git/repos.go @@ -50,6 +50,7 @@ func init() { }, Commands: map[string]*ice.Command{ ice.CTX_INIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + m.Conf(REPOS, kit.MDB_HASH, "") _repos_insert(m, path.Base(kit.Pwd()), kit.Pwd()) m.Cmd(nfs.DIR, kit.SSH_USR, "name,path").Table(func(index int, value map[string]string, head []string) { _repos_insert(m, value[kit.MDB_NAME], value[kit.MDB_PATH])