Skip to content

Commit

Permalink
demo:command run
Browse files Browse the repository at this point in the history
  • Loading branch information
luoliwoshang committed Jan 16, 2025
1 parent 2053c72 commit adde0ab
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions _demo/commandrun/commandrun.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package main

import (
"bytes"
"os/exec"
)

func main() {
var data bytes.Buffer
cmd := exec.Command("ls", "-l")
cmd.Stdout = &data
err := cmd.Run()
if err != nil {
panic(err)
}
println("len:", len(data.Bytes()))
println("data:", data.String())
}

0 comments on commit adde0ab

Please sign in to comment.