Created
August 6, 2022 03:34
-
-
Save dele454/03b5d6db27c12d8f10c0857a185a79d6 to your computer and use it in GitHub Desktop.
Part 1 - CSV Transformation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// WriteReportToStdOut writes report to stdout | |
func (t *TransformationReporter) WriteReportToStdOut(ctx context.Context) error { | |
var err error | |
path := utils.RootDir() | |
// create template | |
tmpl, err := template.Must(template.New("STDOUT"), err). | |
ParseFiles(path + "/internal/transform/template/report.tmpl") | |
if err != nil { | |
return err | |
} | |
// apply tmpl to data | |
var processed bytes.Buffer | |
err = tmpl.ExecuteTemplate(&processed, "report.tmpl", t) | |
if err != nil { | |
return err | |
} | |
// write output to stdout | |
w := bufio.NewWriter(os.Stdout) | |
_, err = w.WriteString(processed.String()) | |
if err != nil { | |
return err | |
} | |
// flush buffer | |
err = w.Flush() | |
if err != nil { | |
return err | |
} | |
return nil | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment