Skip to main content
Brave Programmer Logo

BraveProgrammer

BraveProgrammer

HomeProjectsBlogsCoursesLessonsAbout

Site footer

BraveProgrammer

Free coding courses, practical tutorials, and real projects from BraveProgrammer. Learn web development with React, Next.js, and TypeScript.

Navigation

  • Home
  • Projects
  • Blogs
  • Courses

Resources

  • About
  • Lessons

© 2026 BraveProgrammer. All rights reserved.

  1. Courses
  2. /
  3. Go Programming Bootcamp

Lesson 32 of 60 · Go

Profiling Go Applications with pprof

Duration: 15 minutes

Runtime Profilers

This lesson explains the main concept clearly with beginner-friendly examples and background so you can learn why the code works.

The net/http/pprof package exposes profiling data over HTTP.

import _ "net/http/pprof"

func main() {
    go func() { http.ListenAndServe(":6060", nil) }()
    // rest of your app …
}

Visit http://localhost:6060/debug/pprof/ and click heap, goroutine, profile.

Generating a CPU profile manually

$ go test -bench=BenchmarkXYZ -benchmem -cpuprofile=cpu.out
$ go tool pprof cpu.out
(pprof) top

Visualizing with graphviz

$ go tool pprof -http=:8080 cpu.out

Info

Enable runtime/trace for detailed execution traces (go tool trace).

Previous: Building and Publishing a Go BinaryNext: Working with Environment Variables