Explorar el Código

Write report only when leaks are found

Cristhian Amaya hace 7 años
padre
commit
92bb4ea6fc
Se han modificado 1 ficheros con 4 adiciones y 0 borrados
  1. 4 0
      main.go

+ 4 - 0
main.go

@@ -345,6 +345,10 @@ func run() ([]Leak, error) {
 // writeReport writes a report to a file specified in the --report= option.
 // writeReport writes a report to a file specified in the --report= option.
 // Default format for report is JSON. You can use the --csv option to write the report as a csv
 // Default format for report is JSON. You can use the --csv option to write the report as a csv
 func writeReport(leaks []Leak) error {
 func writeReport(leaks []Leak) error {
+	if len(leaks) == 0 {
+		return nil
+	}
+
 	var err error
 	var err error
 	log.Infof("writing report to %s", opts.Report)
 	log.Infof("writing report to %s", opts.Report)
 	if strings.HasSuffix(opts.Report, ".csv") {
 	if strings.HasSuffix(opts.Report, ".csv") {