get.porter.sh/porter@v1.3.0/pkg/porter/examples/capture_output_example_test.go (about) 1 package examples_test 2 3 import ( 4 "bytes" 5 "context" 6 "fmt" 7 "log" 8 9 "get.porter.sh/porter/pkg/porter" 10 ) 11 12 func ExamplePorter_captureOutput() { 13 // Create an instance of the Porter application 14 p := porter.New() 15 16 // Save output to a buffer 17 output := bytes.Buffer{} 18 p.Out = &output 19 20 // porter schema 21 err := p.PrintManifestSchema(context.Background()) 22 if err != nil { 23 log.Fatal(err) 24 } 25 26 // Print the json schema for porter 27 fmt.Println(output.String()) 28 }