修改序列化的projectName的判断

This commit is contained in:
huangsimin@fusen.cn 2023-11-28 17:19:02 +08:00
parent c0cbff775f
commit 4f231d545b
2 changed files with 14 additions and 2 deletions

View File

@ -923,7 +923,7 @@ func getAllServiceName() (result []string) {
}
// 获取项目的参数
func getServiceNameAndProjectName(dir string) (serviceName string, projectName string, projectLastName string) {
func getServiceNameAndProjectName(dir string) (serviceName string, projectName string, goModeName string) {
ifile, err := ini.Load(dir + "/service_config.ini")
if err != nil {
@ -960,7 +960,18 @@ func getServiceNameAndProjectName(dir string) (serviceName string, projectName s
}
paths := strings.Split(projectName, "/")
projectLastName = paths[len(paths)-1]
goModeName = paths[len(paths)-1]
moddata, err := os.ReadFile("go.mod")
if err != nil {
panic(err)
}
result := regexp.MustCompile(`module\s+([a-zA-Z_\-]+)`).FindAllStringSubmatch(string(moddata), 1)
if len(result) == 0 {
panic("无法找到go.mod 获取 module信息")
}
goModeName = result[0][1]
return
}

View File

@ -11,6 +11,7 @@ import (
"net/url"
"reflect"
"strings"
"time"
)
var fusen *env.Fusen[config.Config]