diff --git a/goutils/proto_build/main.go b/goutils/proto_build/main.go index d6e1cc9..087eab4 100644 --- a/goutils/proto_build/main.go +++ b/goutils/proto_build/main.go @@ -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 } diff --git a/goutils/proto_build/tpls/http_grpc_method_var.tpl b/goutils/proto_build/tpls/http_grpc_method_var.tpl index 41ce22f..99e850a 100644 --- a/goutils/proto_build/tpls/http_grpc_method_var.tpl +++ b/goutils/proto_build/tpls/http_grpc_method_var.tpl @@ -11,6 +11,7 @@ import ( "net/url" "reflect" "strings" + "time" ) var fusen *env.Fusen[config.Config]