Created
November 8, 2022 20:26
-
-
Save BetterProgramming/5a3e7da4f5589da9af8cc6bac77c37c6 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 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