From 9461ad77edba82cc401557f4a90207dd063d9a74 Mon Sep 17 00:00:00 2001 From: ayflying Date: Mon, 10 Feb 2025 16:05:26 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmd/make.go | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/cmd/make.go b/cmd/make.go index d52f924..bd0ee9b 100644 --- a/cmd/make.go +++ b/cmd/make.go @@ -62,16 +62,19 @@ func (c *cMake) Api() { func (c *cMake) Act(id int) (err error) { filePath := fmt.Sprintf("api/act/v1/act%v.go", id) //生成文件不覆盖 - if gfile.Exists(filePath) { - return + if !gfile.Exists(filePath) { + err = gfile.PutContents(filePath, "package v1\n") } - err = gfile.PutContents(filePath, "package v1\n") + filePath = fmt.Sprintf("internal/game/act/act%d/act%d.go", id, id) - //fileStr := gfile.GetContents(getFilePath) - get, err := fs.ReadFile(ConfigFiles, "make/act") - fileStr := string(get) - fileStr = gstr.Replace(fileStr, "{id}", gconv.String(id)) - err = gfile.PutContents(filePath, fileStr) + //生成文件不覆盖 + if !gfile.Exists(filePath) { + //fileStr := gfile.GetContents(getFilePath) + get, _ := fs.ReadFile(ConfigFiles, "make/act") + fileStr := string(get) + fileStr = gstr.Replace(fileStr, "{id}", gconv.String(id)) + err = gfile.PutContents(filePath, fileStr) + } return } @@ -79,15 +82,14 @@ func (c *cMake) Act(id int) (err error) { func (c *cMake) Logic(name string) (err error) { var filePath = fmt.Sprintf("internal/logic/%s/%s.go", name, name) //生成文件不覆盖 - if gfile.Exists(filePath) { - return + if !gfile.Exists(filePath) { + //fileStr := gfile.GetContents("./make/logic") + get, _ := fs.ReadFile(ConfigFiles, "make/act") + fileStr := string(get) + fileStr = gstr.Replace(fileStr, "{package}", name) + fileStr = gstr.Replace(fileStr, "{name}", gstr.CaseCamel(name)) + err = gfile.PutContents(filePath, fileStr) } - //fileStr := gfile.GetContents("./make/logic") - get, err := fs.ReadFile(ConfigFiles, "make/act") - fileStr := string(get) - fileStr = gstr.Replace(fileStr, "{package}", name) - fileStr = gstr.Replace(fileStr, "{name}", gstr.CaseCamel(name)) - err = gfile.PutContents(filePath, fileStr) return }