NetLife Guru

Open source Go packages for fast, maintainable web systems. Built with a documentation-first approach.

Product
OverviewGolang packagesNews
Documentation
DocumentationGo LoggerGo RouterGo DB Form
Company
OverviewContactNewsGitHub
Community / Support
Supportinfo@netlife.guru
© 2026 NetLife Guru. All rights reserved.
GitHubinfo@netlife.guru
NetLife GuruNetLife GuruNetLife Guru
NetLife GuruNetLife GuruNetLife Guru
OverviewDocumentationNewsSupportContact

Golang packages

About
LoggingHealth ChecksProfilingMulti-Server SupportStatic FilesRate LimitingPanic RecoveryCustom 404 HandlerCustom 404 PageError Handling
RouterFeatures

Profiling

Enable Go pprof profiling endpoints for runtime performance analysis, memory inspection, and debugging.

The router package can start a dedicated HTTP profiling server using Go’s standard net/http/pprof tooling.

Profiling is useful for:

  • performance analysis
  • memory inspection
  • CPU profiling
  • goroutine debugging
  • allocation tracking
  • production troubleshooting

Enable Profiling

r.EnableProfiling("localhost:6060")

This starts a dedicated internal HTTP server exposing standard Go profiling endpoints.

Default dashboard:

http://localhost:6060/debug/pprof/

Example:

package main

import (
	"net/http"

	"github.com/netlifeguru/router"
)

func main() {
	r := router.New()

	r.EnableProfiling("localhost:6060")

	r.GET("/", func(w http.ResponseWriter, req *http.Request, ctx *router.Context) {
		w.Write([]byte("hello"))
	})

	r.ListenAndServe(":8080")
}

Available Endpoints

Once enabled, the following endpoints become available:

/debug/pprof/
/debug/pprof/heap
/debug/pprof/profile
/debug/pprof/goroutine
/debug/pprof/allocs
/debug/pprof/block
/debug/pprof/mutex

These endpoints are provided by Go’s standard profiling package.


Example CPU Profile

Capture a 30-second CPU profile:

go tool pprof http://localhost:6060/debug/pprof/profile?seconds=30

Open the interactive profiling UI:

go tool pprof -http=:8081 cpu.prof

Security Notes

Profiling endpoints expose internal runtime information and should not be publicly accessible.

Recommended practices:

  • bind profiling to localhost
  • expose profiling only inside trusted networks
  • disable profiling in public production environments
  • protect profiling endpoints behind authentication or firewalls

Example:

r.EnableProfiling("127.0.0.1:6060")

Notes

The profiling server runs independently from the main HTTP router server.

This allows profiling endpoints to remain isolated from public application traffic while still providing full runtime inspection capabilities.

Health Checks

Add liveness and readiness endpoints to expose service health for containers, load balancers, and orchestration platforms.

Multi-Server Support

Run multiple HTTP listeners simultaneously using a single router instance for internal APIs, public endpoints, admin panels, or multi-port deployments.

On this page

Enable ProfilingAvailable EndpointsExample CPU ProfileSecurity NotesNotes