github.com/josephvusich/fdf@v0.0.0-20230522095411-9326dd32e33f/report.go (about) 1 package main 2 3 import ( 4 "encoding/json" 5 "fmt" 6 "os" 7 8 "github.com/josephvusich/fdf/report" 9 ) 10 11 func writeReport(path string, pairs, namePairs [][]string) error { 12 if path == "" { 13 return nil 14 } 15 16 fmt.Printf("Writing %s...\n", path) 17 18 f, err := os.Create(path) 19 if err != nil { 20 return err 21 } 22 defer f.Close() 23 24 enc := json.NewEncoder(f) 25 enc.SetIndent("", " ") 26 return enc.Encode(&report.Report{ 27 ContentMatches: pairs, 28 NameMatches: namePairs, 29 }) 30 }