Skip to content

Instantly share code, notes, and snippets.

@BetterProgramming
Created November 8, 2022 20:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BetterProgramming/5a3e7da4f5589da9af8cc6bac77c37c6 to your computer and use it in GitHub Desktop.
Save BetterProgramming/5a3e7da4f5589da9af8cc6bac77c37c6 to your computer and use it in GitHub Desktop.
func Start(w io.Writer) error {
tracing.Lock()
defer tracing.Unlock()
if err := runtime.StartTrace(); err != nil {
return err
}
go func() {
for {
data := runtime.ReadTrace()
if data == nil {
break
}
w.Write(data)
}
}()
tracing.enabled.Store(true)
return nil
}​
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment