code: func Profile(w http.ResponseWriter, r *http.Request) {
  	sec, _ := strconv.ParseInt(r.FormValue("seconds"), 10, 64)
  	if sec == 0 {
  		sec = 30
  	}
  
  	if durationExceedsWriteTimeout(r, float64(sec)) {
  		w.Header().Set("Content-Type", "text/plain; charset=utf-8")
  		w.Header().Set("X-Go-Pprof", "1")
  		w.WriteHeader(http.StatusBadRequest)
  		fmt.Fprintln(w, "profile duration exceeds server's WriteTimeout")
  		return
  	}
  
  	// Set Content Type assuming StartCPUProfile will work,
  	// because if it does it starts writing.
  	w.Header().Set("Content-Type", "application/octet-stream")
  	if err := pprof.StartCPUProfile(w); err != nil {
  		// StartCPUProfile failed, so no writes yet.
  		// Can change header back to text content
  		// and send error code.
  		w.Header().Set("Content-Type", "text/plain; charset=utf-8")
  		w.Header().Set("X-Go-Pprof", "1")
  		w.WriteHeader(http.StatusInternalServerError)
  		fmt.Fprintf(w, "Could not enable CPU profiling: %s\n", err)
  		return
  	}
  	sleep(w, time.Duration(sec)*time.Second)
  	pprof.StopCPUProfile()
  }
docs: // Profile responds with the pprof-formatted cpu profile.
  // The package initialization registers it as /debug/pprof/profile.