Skip to content

v1.20.7

Latest

Choose a tag to compare

@andeya andeya released this 31 Dec 18:33

Changelog

Added

New Packages

  • shutdown: Graceful shutdown and reboot utility package

    • Provides graceful shutdown and reboot functionality for Go applications
    • Handles system signals (SIGINT, SIGTERM, SIGUSR2)
    • Supports configurable timeout and hooks for cleanup
    • Cross-platform support (Unix/Linux and Windows)
    • Context-based shutdown control
  • shutdown/inheritnet: Network listener inheritance for graceful restarts

    • Provides Listen functions that support inheriting connections from parent process
    • Compatible with systemd socket activation (LISTEN_FDS)
    • Enables zero-downtime deployments with connection preservation
    • A practical application example of the shutdown package
  • coarsetime: Fast, coarse-grained time access

    • Faster alternative to time.Now() with configurable precision
    • Inspired by Linux's CLOCK_REALTIME_COARSE and CLOCK_MONOTONIC_COARSE
    • Provides both wall clock time and monotonic time
    • Default 100ms precision with customizable frequency

New Functions

  • conv.SystemEndian(): Returns the byte order of the current system

    • Detects system endianness at startup
    • Returns binary.LittleEndian or binary.BigEndian
  • conv.EnsurePointerInitialized(): Initializes nil pointers recursively

    • Traverses pointer chains and interfaces
    • Initializes nil pointers with zero values
    • Returns result.VoidResult for error handling
  • syncutil.AtomicValue[T]: Generic wrapper for atomic.Value

    • Type-safe atomic load and store operations
    • Returns Option[T] from Load for nil-safety
    • Supports Store, Swap, and CompareAndSwap operations

Changed

  • shutdown: Enhanced shutdown and reboot logic with context support
    • Updated shutdown and reboot methods to accept context parameters
    • Improved logging functionality with context in log messages
    • Refactored internal methods to separate logic from exit handling
    • Better testability without terminating processes

Improved

  • Test Coverage: Simplified and enhanced tests across packages
    • Reduced test code volume by ~58% while maintaining >95% coverage
    • Improved test structure and reduced redundancy
    • Added comprehensive tests for new features