修改自动grpc不需要在项目配置
This commit is contained in:
parent
702248cc8f
commit
ac925c3424
|
@ -127,16 +127,13 @@ go run -gcflags="-N" proto/goutils/proto_build/main.go client`
|
||||||
log.Println(err)
|
log.Println(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
projectName := ""
|
projectName := "gitlab.fusenpack.com/backend/grpc"
|
||||||
projectLastName := ""
|
|
||||||
ServiceName := ""
|
|
||||||
|
|
||||||
CheckGomodBasicPackage()
|
CheckGomodBasicPackage()
|
||||||
ExecProtoc(workspaceDir, serviceProtoDir, genDir, packageName, projectName)
|
ExecProtoc(workspaceDir, serviceProtoDir, genDir, packageName, projectName)
|
||||||
|
GitignoreGenCheck()
|
||||||
|
|
||||||
ExecCreateConfig(ServiceName, projectLastName)
|
|
||||||
ExecCreateAutoGrpc(genDir, packageName)
|
ExecCreateAutoGrpc(genDir, packageName)
|
||||||
ExecCreateAutoLogic(workspaceDir, ServiceName, genDir, packageName, projectLastName)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func ExecCreateConfig(ServiceName, ProjectName string) {
|
func ExecCreateConfig(ServiceName, ProjectName string) {
|
||||||
|
@ -887,6 +884,7 @@ func importFileCmdStr(importFile string, projectName string) string {
|
||||||
log.Printf("模板执行失败:%v\n", err)
|
log.Printf("模板执行失败:%v\n", err)
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
// log.Println(buf.String())
|
||||||
return buf.String()
|
return buf.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1531,3 +1529,28 @@ func getGrpcFileServiceName(decl ast.Decl) (string, string, bool) {
|
||||||
}
|
}
|
||||||
return "", "", false
|
return "", "", false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 检测gitignore gen是否存在
|
||||||
|
func GitignoreGenCheck() {
|
||||||
|
|
||||||
|
gitignoreFile := "./.gitignore"
|
||||||
|
|
||||||
|
data, err := os.ReadFile(gitignoreFile)
|
||||||
|
if err != nil {
|
||||||
|
log.Println(err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, line := range strings.Split(string(data), "\n") {
|
||||||
|
if strings.Trim(line, " ") == "gen" {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
data = append(data, []byte("\ngen\n")...)
|
||||||
|
|
||||||
|
err = os.WriteFile(gitignoreFile, data, 0644)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"reflect"
|
"reflect"
|
||||||
|
"fusen-basic/env"
|
||||||
|
|
||||||
"github.com/nacos-group/nacos-sdk-go/v2/clients/naming_client"
|
"github.com/nacos-group/nacos-sdk-go/v2/clients/naming_client"
|
||||||
"github.com/nacos-group/nacos-sdk-go/v2/vo"
|
"github.com/nacos-group/nacos-sdk-go/v2/vo"
|
||||||
|
@ -14,6 +15,10 @@ import (
|
||||||
var namingClient naming_client.INamingClient
|
var namingClient naming_client.INamingClient
|
||||||
var groupName string
|
var groupName string
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
AutoGrpcInit(env.StartAutoGrpc())
|
||||||
|
}
|
||||||
|
|
||||||
// AutoGrpcInit auto grpc 必须调用初始化
|
// AutoGrpcInit auto grpc 必须调用初始化
|
||||||
func AutoGrpcInit(obj any) {
|
func AutoGrpcInit(obj any) {
|
||||||
value := reflect.ValueOf(obj)
|
value := reflect.ValueOf(obj)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user