Created
March 23, 2021 15:05
-
-
Save dtest11/2136de08addece4c35d884e180813f91 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"bytes" | |
"fmt" | |
"log" | |
"os/exec" | |
"time" | |
) | |
func main() { | |
for i := 0; i < 10; i++ { | |
args := []string{ | |
"tool", | |
"pprof", | |
"http://localhost:6060/debug/pprof/heap", | |
} | |
cmd := exec.Command("go", args...) | |
var stdout, stderr bytes.Buffer | |
cmd.Stdout = &stdout | |
cmd.Stderr = &stderr | |
err := cmd.Run() | |
if err != nil { | |
log.Fatalf("cmd.Run() failed with %s\n", err) | |
} | |
outStr, errStr := string(stdout.Bytes()), string(stderr.Bytes()) | |
fmt.Printf("out:\n%s\nerr:\n%s\n", outStr, errStr) | |
<-time.After(1*time.Second) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment