fix bug
This commit is contained in:
19
main.go
19
main.go
@@ -26,14 +26,21 @@ func main() {
|
|||||||
protogen.Options{}.Run(func(gen *protogen.Plugin) error {
|
protogen.Options{}.Run(func(gen *protogen.Plugin) error {
|
||||||
gen.SupportedFeatures = uint64(pluginpb.CodeGeneratorResponse_FEATURE_PROTO3_OPTIONAL)
|
gen.SupportedFeatures = uint64(pluginpb.CodeGeneratorResponse_FEATURE_PROTO3_OPTIONAL)
|
||||||
|
|
||||||
|
// 以代码生成根目录为基准;gen.Files 无 service 时不创建 internal/{server,logic}
|
||||||
|
serviceCount := 0
|
||||||
|
for _, f := range gen.Files {
|
||||||
|
serviceCount += len(f.Services)
|
||||||
|
}
|
||||||
|
if serviceCount == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
if !utils.PathExists("./internal") {
|
if !utils.PathExists("./internal") {
|
||||||
os.MkdirAll("./internal", 0755)
|
os.MkdirAll("./internal", 0755)
|
||||||
}
|
}
|
||||||
|
|
||||||
if !utils.PathExists("./internal/server") {
|
if !utils.PathExists("./internal/server") {
|
||||||
os.MkdirAll("./internal/server", 0755)
|
os.MkdirAll("./internal/server", 0755)
|
||||||
}
|
}
|
||||||
|
|
||||||
if !utils.PathExists("./internal/logic") {
|
if !utils.PathExists("./internal/logic") {
|
||||||
os.MkdirAll("./internal/logic", 0755)
|
os.MkdirAll("./internal/logic", 0755)
|
||||||
}
|
}
|
||||||
@@ -47,13 +54,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
err := generateNewServerFile(ServicesName)
|
return generateNewServerFile(ServicesName)
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user