Debug Build Profiling Support: Code improvement suggestions for PR#1471#1476
Merged
ccojocar merged 4 commits intosecurego:masterfrom Jan 23, 2026
Merged
Conversation
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.
|
Codecov Report❌ Patch coverage is
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. 🚀 New features to boost your workflow:
|
Contributor
|
Nice! I'll close the previous pull request since this is much cleaner with constants for exit codes and so on. |
Contributor
Author
ccojocar
approved these changes
Jan 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Improvements to PR #1471: Debug Build Profiling Support