From 8ec58eec61fa261dce2bfb03922d6865230f4ed7 Mon Sep 17 00:00:00 2001 From: Terry Howe Date: Mon, 15 Jul 2024 11:16:14 -0600 Subject: [PATCH] chore: Update go script for data capture (#362) Update the go script documentation for stdout capture. This works for 1.2, but stderr capture is not part of 1.2. --------- Signed-off-by: Terry Howe Co-authored-by: Billy Zha --- versioned_docs/version-1.2/how_to_guides/go_script.mdx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/versioned_docs/version-1.2/how_to_guides/go_script.mdx b/versioned_docs/version-1.2/how_to_guides/go_script.mdx index 22808453..d620b0bb 100644 --- a/versioned_docs/version-1.2/how_to_guides/go_script.mdx +++ b/versioned_docs/version-1.2/how_to_guides/go_script.mdx @@ -24,8 +24,11 @@ func main() { args := []string{"repo", "ls", "mcr.microsoft.com"} cmd := root.New() cmd.SetArgs(args) + builder := &strings.Builder{} + cmd.SetOut(builder) fmt.Printf("Executing 'oras %s':", strings.Join(args, " ")) err := cmd.Execute() + fmt.Println(builder.String()) if err != nil { fmt.Errorf("Failed to execute : %w", err) os.Exit(-1)