Skip to content

Commit

Permalink
chore: Update go script for data capture (#362)
Browse files Browse the repository at this point in the history
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 <[email protected]>
Co-authored-by: Billy Zha <[email protected]>
  • Loading branch information
Terry Howe and qweeah authored Jul 15, 2024
1 parent f5e6c4d commit 8ec58ee
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions versioned_docs/version-1.2/how_to_guides/go_script.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 8ec58ee

Please sign in to comment.