diff --git a/desc_source.go b/desc_source.go index 617839e..fd40b27 100644 --- a/desc_source.go +++ b/desc_source.go @@ -327,10 +327,11 @@ func WriteProtoFiles(outProtoDirPath string, descSource DescriptorSource, symbol } return fmt.Errorf("failed to create file %q: %v", filePath, err) } - _ = f.Close() if err := pr.PrintProtoFile(fd, f); err != nil { + _ = f.Close() return fmt.Errorf("failed to write file %q: %v", filePath, err) } + _ = f.Close() } return nil }