Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Preserve new lines when buffering
Instead of writing a `println()` which prints to stdout, write the new line character tot he `io.Writer`, this way it is preserved, otherwise, the character is lost. This way, the code of `tf-summarize` can be used as a library inside your Go code rather than a executable binary and the expected output is the same. Simple test code: ``` package main import ( "bytes" "os" "github.com/dineshba/tf-summarize/parser" "github.com/dineshba/tf-summarize/reader" "github.com/dineshba/tf-summarize/writer" ) func main() { planOutputFile := "/tmp/plan" newReader, err := reader.CreateReader(os.Stdin, []string{planOutputFile}) if err != nil { panic(err) } input, err := newReader.Read() newParser, err := parser.CreateParser(input, newReader.Name()) terraformState, err := newParser.Parse() if err != nil { panic(err) } terraformState.FilterNoOpResources() newWriter := writer.CreateWriter(false, false, false, true, false, terraformState) var b bytes.Buffer newWriter.Write(&b) println(b.String()) } ```
- Loading branch information