This commit is contained in:
John Guo
2023-07-05 09:49:25 +08:00
committed by GitHub
parent ba2a7e4417
commit c90e9311e3

View File

@ -324,6 +324,10 @@ func (c CGenService) checkAndUpdateMain(srcFolder string) (err error) {
mainFilePath = gfile.Join(gfile.Dir(gfile.Dir(gfile.Dir(logicFilePath))), "main.go")
mainFileContent = gfile.GetContents(mainFilePath)
)
// No main content found.
if mainFileContent == "" {
return nil
}
if gstr.Contains(mainFileContent, importStr) {
return nil
}
@ -331,6 +335,10 @@ func (c CGenService) checkAndUpdateMain(srcFolder string) (err error) {
if err != nil {
return err
}
// No match.
if len(match) < 2 {
return nil
}
lines := garray.NewStrArrayFrom(gstr.Split(match[1], "\n"))
for i, line := range lines.Slice() {
line = gstr.Trim(line)