Compile Time DI Tool dig Release Notes(v1.0.12 and v1.0.13)

v1.0.13 (2026-07-29)

Compared to the previous version v1.0.11, this release includes 16 improvements covering version system, error handling, closure validation, and other important features.

:rocket: New Features

Version Information System (Issue #15)

  • Added -version CLI flag; run digen -version to display version information
  • Supports multiple version sources (ldflags injection first, VCS info fallback)
  • Automatically parses git describe format (supports -dirty, -N-g<hash> suffixes)
  • Added Mage build system with standardized tasks: build, install, test, vet
# Check version
digen -version
# digen v1.0.13+0
#   commit: 17be99fc
#   built:  2026-07-29 18:48:05 +08:00

# Build with Mage
mage build    # auto-injects version info
mage install  # install to $GOPATH/bin
mage test     # run tests

Multi-Entry Architecture Example

  • Added multi-entry architecture example with shared setup module
  • Demonstrates how to organize dependencies for complex applications

:bug: Important Fixes

Provide Closure Signature Validation (Issue #11)

  • Before: Illegal signatures like dig.Provide(func() (string, int, error) {...}) would generate code that fails to compile
  • After: digen now rejects such code before generation and outputs a clear error
Package example/gen_failures/provide_too_many_returns:
    extract and build nodes: func anonymous provide function: too many return values (3),
        only (T) or (T, error) are allowed

Panic → Structured Error Returns (Issue #12)

  • Before: Errors triggered panics, outputting Go runtime stacks that were hard to diagnose
  • After: All errors are returned as structured errors, including package name, file location, and fix suggestions
Package example/gen_failures/missing_provider:
    extract and build nodes: no provider for type *struct{} with name "missing"
        required by dig_invoke_1 (closure) at di.go:17
        (no provider for this type at all)
      💡 Fix: add a provider for *struct{} via dig.Provide or dig.Supply

Logf Package Alias Fix

  • Fixed Logf reference resolution error under -alias=full mode

:light_bulb: Error Message Enhancements (Issue #13, #14)

Actionable Fix Suggestions

All error messages now include 💡 Fix: suggestions with scenario-specific guidance:

Scenario Fix Suggestion
Missing Provider 💡 Fix: add a provider for Type via dig.Provide or dig.Supply
Name Mismatch 💡 Fix: rename parameter to 'name' to match the only named provider
Circular Dependency 💡 Fix: break the cycle by removing or restructuring one of the dependencies
Unused Provider 💡 Fix: either add an Invoke that consumes Type, or remove this provider

Always Show Detailed Errors

  • Before: Only showed “X package(s) failed”; required -debug flag for details
  • After: Always displays the specific error reason and fix suggestion for each failed package
[digen] failed packages:
  Package example/gen_failures/cycle:
    extract and build nodes: circular dependency detected
        Provide: newA -> *A -> Provide: newB -> *B
      💡 Fix: break the cycle by removing or restructuring one of the dependencies
  Package example/gen_failures/missing_provider:
    extract and build nodes: no provider for type *struct{} with name "missing"
    ...
[digen] generated 4/21 packages (17 failed), cost: 1.2s

:building_construction: Internal Improvements

  • Cache built-in error type in package variable to reduce repeated allocations
  • Extract alias management into a standalone AliasManager component
  • Version resolution priority: ldflags > VCS info > default

:memo: New Examples

Added gen_failures test cases covering various error scenarios:

  • provide_no_return: Provide closure with no return value
  • provide_bad_error: Second return value is not error
  • provide_too_many_returns: Too many return values
  • missing_provider: Missing provider
  • cycle: Circular dependency
  • closure_capture: Closure capturing local variables
  • control_flow: Illegal operations inside control flow
  • And more scenarios

v1.0.12 (2026-07-21)

:light_bulb: Core Improvements

Cross-Package Visibility Check

  • Check cross-package method and type visibility at code generation time
  • Detect and report references to unexported members earlier

Named Injection Error Message Improvements

  • Provide more precise error hints for named instance injection scenarios
  • List all available names when multiple providers exist for the same type

Illegal dig.Option Nesting Detection

  • Added validation against illegal dig.Option nesting
  • Prevents incorrectly embedding another dig.Build inside dig.Build

Unified Provider Lookup Logic

  • Refactored resolveProvider function to unify the Provider lookup path
  • Reduced code duplication and improved maintainability

:bug: Fixes

  • Method visibility check in closure body: Fixed compile error when closures reference unexported methods
  • Bare function call alias in Module closure: Fixed missing package alias for bare function calls inside Module closures
  • Generator error checking: Fixed the issue where errors were not checked when provider results were ignored
  • Reduced handleFuncLit cyclomatic complexity: Refactored function for better readability

:memo: Documentation Updates

  • Updated documentation for v1.0.11 named instance injection
  • Added bilingual issue documents (#11-#15)

:clipboard: Upgrade Guide

Upgrading from v1.0.11

No code changes required. This update is purely additive and fixes; all existing APIs remain backward compatible.

Recommended Actions

# Update digen tool
go install github.com/shanjunmei/dig/cmd/digen@v1.0.13

# Update dependency in your project
go get github.com/shanjunmei/dig@v1.0.13
go mod tidy

# Regenerate code
digen ./...

Try the New Features

# View version info
digen -version

# Detailed errors are now shown by default (-debug only controls debug logs)
digen ./...

# Test failure cases
cd example
digen -unused=ignore ./...

:link: Related Issues

# Type Description
#11 Bug Missing Provide closure signature validation generates invalid code
#12 Enhancement Replace panics with structured error returns
#13 Enhancement Add actionable fix suggestions to all error messages
#14 Enhancement Always show detailed errors for all failed packages
#15 Feature Version info system and Mage build support

:package: Installation

go get github.com/shanjunmei/dig@v1.0.13
go install github.com/shanjunmei/dig/cmd/digen@v1.0.13

Go version requirement: Go 1.21+


:page_facing_up: License

MIT License