Created
November 8, 2022 20:26
-
-
Save BetterProgramming/5245f3fa6bbf1d7d09eab77fee2076fd 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
func Trace(w io.Writer) error { | |
if err := runtime.StartTrace(); err != nil { | |
return err | |
} | |
defer runtime.StopTrace() | |
go func() { | |
for { | |
data := runtime.ReadTrace() | |
if data == nil { | |
break | |
} | |
w.Write(data) | |
} | |
}() | |
return nil | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment