Skip to content

Releases: rameshsunkara/go-rest-api-example

Add Go 1.25 Flight Recorder Integration for Performance Debugging

11 Nov 02:31
2515498

Choose a tag to compare

Release Notes - v2.1.0 🚀

Release Date: November 10, 2025

🎉 What's New

Go 1.25 Flight Recorder Integration

The biggest feature in this release is the integration of Go 1.25's Flight Recorder for automatic performance tracing. This powerful diagnostic tool helps you debug production performance issues without any code changes.

Key Capabilities

Automatic Slow Request Detection - Captures execution traces for requests taking > 500ms
Zero Overhead When Disabled - Production-safe with opt-in configuration
Visual Trace Analysis - Use go tool trace to debug performance bottlenecks
Smart Buffer Management - Rolling 1 MiB buffer with 1-second retention window

Go 1.25 Upgrade

  • Upgraded from Go 1.24 → Go 1.25
  • Updated all dependencies to latest stable versions
  • Enhanced CI/CD pipeline for Go 1.25 support

Enhanced Developer Experience

New Commands

make trace TRACE_FILE=./traces/slow-request-GET-orders-1234567890.trace

Better Documentation

  • 🎨 Enhanced README with emojis and visual improvements
  • 📚 Collapsible sections for better readability
  • 📋 Added .env.example template

Improved Configuration

  • New enableTracing environment variable

📦 What's Included

New Components

Component Description
pkg/flightrecorder Flight recorder package with clean API
.env.example Environment configuration template
make trace Trace analysis command

🔧 Configuration

New Environment Variables

# Enable flight recorder for slow request tracing
enableTracing=true  # Default: false

Trace Configuration

  • Threshold: 500ms (requests slower than this are traced)
  • Buffer Size: 1 MiB (rolling buffer)
  • Retention: 1 second (minimum trace age)
  • Output Directory: ./traces/

📊 Performance Impact

Mode Memory Overhead CPU Overhead Notes
Disabled 0 bytes 0% Default, production-safe
Enabled ~1 MiB ~1-2% Rolling buffer, minimal impact
Capturing +file size Negligible Non-blocking write

🚀 Getting Started

Quick Start

# 1. Pull latest changes
git pull origin main

# 2. Update dependencies
go mod tidy

# 3. Copy environment template
cp .env.example .env

# 4. Enable tracing (optional)
echo "enableTracing=true" >> .env

# 5. Start the application
make start

Analyzing Traces

# Application automatically captures slow requests
# Traces are saved to ./traces/

# List available traces
ls -lhtr ./traces/

# Analyze a trace
make trace TRACE_FILE=./traces/slow-request-GET-orders-1762824976.trace

🔄 Migration Guide

Upgrading from v1.x

This release is backward compatible with no breaking changes.

Automatic Migration

git pull origin main
go mod tidy
make start  # Works immediately!

Optional: Enable Tracing

# Add to .env file
enableTracing=true

Docker Users

# Rebuild with Go 1.25
docker-compose down
docker-compose build
docker-compose up -d

CI/CD

  • ✅ Updated to Go 1.25
  • ✅ golangci-lint v2.6.2 (latest stable)

🔐 Security

  • No security vulnerabilities introduced
  • Flight recorder only active when explicitly enabled
  • Trace files contain execution data (review before sharing)
  • Added .env to .gitignore (prevents credential leaks)

📖 Learning Resources

💬 Feedback

I love to hear your feedback!


MongoDB Connection Architecture Refactor

28 Sep 23:49
e35304c

Choose a tag to compare

🚀 🚀 Release Notes - MongoDB Connection Architecture Refactor

📋 Overview

This release represents a major architectural overhaul focused on MongoDB connection management, dependency upgrades, code organization improvements, and comprehensive test coverage enhancement. The changes improve maintainability, reliability, and follow Go best practices.

✨ Major Features & Improvements

🔧 MongoDB Connection Architecture Redesign

  • Complete refactor of MongoDB connection management from internal/db to dedicated pkg/mongodb package
  • New modular connection system with support for:
    • MongoDB and MongoDB+SRV connection schemes
    • Configurable options using functional pattern (replica sets, read preferences, write concerns)
    • Credential management via sidecar files
    • Connection URL masking for security
    • Comprehensive connection validation and error handling

📦 Package Restructuring & Clean Architecture

  • Migrated logger from internal/logger to pkg/logger for better reusability
  • Extracted configuration management to dedicated internal/config package
  • Improved separation of concerns with cleaner package boundaries

🏗️ Server & Application Improvements

  • Enhanced graceful shutdown with proper context cancellation handling
  • Improved server lifecycle management with better error handling
  • Streamlined main application logic with cleaner separation of setup phases
  • Better configuration loading and validation

🔄 Dependency Updates

  • MongoDB Driver 1.17.4 (latest stable release)
  • Gin Framework 1.11.0 (latest version with security fixes)
  • Updated all dependencies to latest stable versions for security and performance

🛠️ Technical Changes

New Packages & Components

pkg/mongodb/          # MongoDB connection management
├── connection.go     # Connection manager implementation
├── options.go        # Connection options and functional patterns
├── types.go          # Type definitions and credentials
└── url.go            # Connection URL building and validation

pkg/logger/           # Structured logging with zerolog
├── logger.go         # Logger interface and implementation
└── logger_test.go    # Comprehensive logger tests

internal/config/      # Configuration management
├── config.go         # Environment configuration loading
└── config_test.go    # Configuration validation tests

Removed/Refactored Components

  • internal/db/connection.go → ✅ pkg/mongodb/connection.go
  • internal/db/connectionURL.go → ✅ pkg/mongodb/url.go
  • internal/logger/ → ✅ pkg/logger/
  • internal/util/ → ✅ internal/utilities/

🔒 Security Enhancements

  • Input validation for all MongoDB connection parameters
  • Updated dependencies with latest security patches

🚀 DevOps & CI/CD Improvements

  • Enhanced Makefile with comprehensive test coverage reporting
  • Improved Docker configuration for local development
  • VS Code workspace settings for consistent development experience

🐛 Bug Fixes & Stability

  • Improved error handling with proper error wrapping and context
  • Enhanced graceful shutdown preventing resource leaks

🔄 Breaking Changes

⚠️ API Changes (internal packages only - no public API changes):

  • MongoDB connection interfaces moved from internal/db to pkg/mongodb
  • Logger interface relocated to pkg/logger
  • Configuration structure updated in internal/config

🎯 Migration Guide

For developers working with the codebase:

  1. Import path updates for MongoDB connections:

    // Old
    import "github.com/rameshsunkara/go-rest-api-example/internal/db"
    
    // New  
    import "github.com/rameshsunkara/go-rest-api-example/pkg/mongodb"
  2. Logger import changes:

    // Old
    import "github.com/rameshsunkara/go-rest-api-example/internal/logger"
    
    // New
    import "github.com/rameshsunkara/go-rest-api-example/pkg/logger"

v1.1.1 Auto detect race conditions

24 May 13:45
221bdda

Choose a tag to compare

Code changes are here: #57

Fixes panic in tests:

Removes redundant t.Parallel() calls at the top level of test functions that use subtests, ensuring t.Parallel() is only called within subtest closures. This prevents the panic: testing: t.Parallel called multiple times error.

Test structure improvements:

Refactors table-driven tests to use proper parallelization patterns, increasing test isolation and reliability.

General test cleanup:

Ensures consistent error handling and assertion usage across test files.
Fixes race conditions and panics in tests caused by improper use of t.Parallel().
Improves test maintainability and reliability.


In addition to test changes

  • Injects logger to all appropriate functions
  • main.go is now modular and readable
  • Removed deferrun dep which was dealing with signals to cleanup

v1.1.0

25 Mar 18:49
c58ab89

Choose a tag to compare

Changes in this release:

  1. Upgraded Go version to 1.24: Updated the project to use the latest stable version of Go, ensuring better performance, security, and access to new language features.
  2. Upgraded golangci-lint to v2: Integrated the latest version of golangci-lint (v2), improving static code analysis and linting capabilities to catch potential issues early.
  3. Optimized Dockerfile with BuildKit: The Dockerfile now leverages Docker BuildKit for more efficient builds, including enhanced caching and faster layer processing.
  4. Parallelized Build Workflow: The CI build pipeline has been updated to run tests and Docker builds in parallel, reducing build time and improving overall workflow efficiency.

This release focuses on performance improvements, build optimizations, and code quality enhancements.

Full Changelog: v1.0.1...v1.1.0

Makefile and Test execution improvements

24 Nov 10:26
2667778

Choose a tag to compare

  • Updated Makefile to improve readability and maintainability
  • Got rid of in memory mongodb usage for db test and used mtest from offical mongodb.
  • Tests are now executed in parallel
  • Updated redme to improve readbility
  • Increased code coverage

v1.0.0 New features

28 Aug 19:09
63889ff

Choose a tag to compare

Following are the newly added features

API Features:

  1. OWASP Compliant Open API 3 Spec
  2. Middleware for
    • Logging : Helps in debugging and monitoring
    • Authentication : Placeholder for different authentication mechanisms
    • Tracing by Request ID : Helps in debugging
    • Panic Recovery : Helps in keeping the service up
    • Common Security Headers : Keeps the service secure
    • Query Params Validation : Helps in keeping the service secure
  3. Standard Error Handling
    • All errors are handled and returned in a standard format
  4. Versioning
  5. Model Management
    • Generally, the data model used internally is different from the data model exposed to the client.
      This helps in keeping the internal model separate from the exposed model.

Go Application Features:

  1. Configuration Management through Environment Variables
  2. A Makefile to do all common tasks
  3. A Git Action to build, run tests, generate code coverage
  4. Integrated GO Formatter and Linter
  5. Mechanism to load secrets from Sidecar
  6. Enables connecting to multiple databases
  7. Follows the best practices for connecting to MongoDB
  8. Good mocking practises for Unit test patterns
  9. Standard filename conventions for better readability