fix: ignore creating file when empty

This commit is contained in:
zhuyasen 2025-05-30 15:43:11 +08:00
parent da3e2f3afa
commit 69aebc1f1f
1 changed files with 3 additions and 0 deletions

View File

@ -160,6 +160,9 @@ func main() {
func saveGinRouterFiles(f *protogen.File) error {
ginRouterFileContent := router.GenerateFiles(f)
if len(ginRouterFileContent) == 0 {
return nil
}
if !bytes.Contains(ginRouterFileContent, []byte("errors.")) {
ginRouterFileContent = bytes.Replace(ginRouterFileContent, []byte(`"errors"`), []byte(""), 1)
}