Created
June 25, 2025 19:26
-
-
Save lovemycodesnippets/4d3b0bb816f2ada840f0b5905f189d80 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
cmd := exec.Command("kubectl", "logs", "-f", "my-pod", "-n", "default") | |
stdout, err := cmd.StdoutPipe() | |
if err != nil { | |
panic(err) | |
} | |
stderr, err := cmd.StderrPipe() | |
if err != nil { | |
panic(err) | |
} | |
if err := cmd.Start(); err != nil { | |
panic(err) | |
} | |
// Stream both stdout and stderr | |
go io.Copy(os.Stdout, stdout) | |
go io.Copy(os.Stderr, stderr) | |
if err := cmd.Wait(); err != nil { | |
panic(err) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment