Skip to content

Debug Build Profiling Support: Code improvement suggestions for PR#1471#1476

Merged
ccojocar merged 4 commits intosecurego:masterfrom
ravisastryk:improve-pr-1471-profiling
Jan 23, 2026
Merged

Debug Build Profiling Support: Code improvement suggestions for PR#1471#1476
ccojocar merged 4 commits intosecurego:masterfrom
ravisastryk:improve-pr-1471-profiling

Conversation

@ravisastryk
Copy link
Contributor

Improvements to PR #1471: Debug Build Profiling Support

oittaa and others added 3 commits January 18, 2026 17:34
Add CPU and memory profiling capabilities for debug builds using Go build
tags. Profiling code is completely excluded from release builds.

Changes:
- Add profiling_debug.go with -cpuprofile and -memprofile flags (build tag: debug)
- Add build-debug and build-debug-race Makefile targets
- Refactor main() to run() pattern for proper defer handling
- Replace logger.Fatal() with logger.Printf() + return for clean exits
- Pass logger to profiling for consistent [gosec] log prefix

Usage:
  make build-debug
  ./gosec-debug -cpuprofile cpu.prof -memprofile mem.prof ./...
- Encapsulate profiling state in Profiler struct to eliminate package-level mutable state
- Add proper error handling with error returns instead of silent failures
- Add exit code constants (exitSuccess/exitFailure) to replace magic numbers
- Fix Makefile clean target to remove gosec-debug binary
- Add nil logger guard for safety
Replace remaining magic numbers (0, 1) with exitSuccess and exitFailure
constants throughout the run() function for consistency.
@ravisastryk ravisastryk marked this pull request as ready for review January 19, 2026 22:42
@codecov-commenter
Copy link

codecov-commenter commented Jan 19, 2026

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 0% with 56 lines in your changes missing coverage. Please review.
✅ Project coverage is 69.14%. Comparing base (1216c9b) to head (953001a).
⚠️ Report is 168 commits behind head on master.

Files with missing lines Patch % Lines
cmd/gosec/main.go 0.00% 53 Missing ⚠️
cmd/gosec/profiling_release.go 0.00% 3 Missing ⚠️
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1476      +/-   ##
==========================================
+ Coverage   68.49%   69.14%   +0.64%     
==========================================
  Files          75       83       +8     
  Lines        4384     6615    +2231     
==========================================
+ Hits         3003     4574    +1571     
- Misses       1233     1817     +584     
- Partials      148      224      +76     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@oittaa
Copy link
Contributor

oittaa commented Jan 20, 2026

Nice! I'll close the previous pull request since this is much cleaner with constants for exit codes and so on.

@ravisastryk
Copy link
Contributor Author

@ccojocar Can you please review this PR when you get a chance? Thank you for your time.
cc @oittaa

@ccojocar ccojocar merged commit be0fd6d into securego:master Jan 23, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants