get.porter.sh/porter@v1.3.0/pkg/printer/yaml.go (about) 1 package printer 2 3 import ( 4 "fmt" 5 "io" 6 7 "get.porter.sh/porter/pkg/encoding" 8 ) 9 10 // PrintYaml is a printer that prints the provided value in yaml 11 func PrintYaml(out io.Writer, v interface{}) error { 12 b, err := encoding.MarshalYaml(v) 13 if err != nil { 14 return fmt.Errorf("could not marshal value to yaml: %w", err) 15 } 16 fmt.Fprint(out, string(b)) // yaml already includes a trailing newline, so don't print another 17 return nil 18 }