From 1e4862ace811f84f9f1da31fbfce37bc7c27b14b Mon Sep 17 00:00:00 2001 From: Matt Joiner Date: Thu, 10 Jul 2014 00:14:19 +1000 Subject: [PATCH] Start a simpler replacement for davecheney's profile package --- util/profile/profile.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 util/profile/profile.go diff --git a/util/profile/profile.go b/util/profile/profile.go new file mode 100644 index 00000000..74bfae6e --- /dev/null +++ b/util/profile/profile.go @@ -0,0 +1,19 @@ +package profile + +import ( + "log" + "net/http" + _ "net/http/pprof" + "os" +) + +func init() { + if httpAddr := os.Getenv("GOPROF"); httpAddr != "" { + go func() { + err := http.ListenAndServe(httpAddr, nil) + if err != nil { + log.Print(err) + } + }() + } +}