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 }