A command-line tool that generates decorators for Go interfaces using templates to add cross-cutting concerns like metrics and tracing.
GoWrap is a command-line tool that generates decorator implementations for Go interfaces using templates. It solves the problem of manually writing repetitive boilerplate code to add cross-cutting concerns like metrics, logging, tracing, and resilience patterns to existing interfaces. By automating this process, it helps developers maintain cleaner, more focused business logic.
Go developers building services or libraries who need to add observability, resilience, or validation layers to their interfaces without cluttering core logic. It's particularly useful for teams adopting microservices or implementing consistent patterns across a codebase.
Developers choose GoWrap because it drastically reduces boilerplate, enforces consistent patterns via templates, and integrates seamlessly with Go's toolchain (like `go generate`). Its rich set of built-in templates for popular libraries (Prometheus, OpenTelemetry, logrus) means you can add production-ready features in seconds.
GoWrap is a command line tool for generating decorators for Go interfaces
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Includes production-ready templates for Prometheus metrics, OpenTelemetry tracing, logrus logging, and resilience patterns like circuit breaker and retry, reducing implementation time. Evidence: README lists 15+ hosted templates with specific libraries.
Automatically inserts //go:generate instructions to regenerate decorators on interface changes, ensuring consistency with minimal manual effort. Evidence: README highlights this as a default feature with examples.
Supports custom Go templates enhanced with Sprig functions and GoWrap-specific helpers, allowing tailored decorator logic. Evidence: README documents TemplateInputs struct and provides utility functions like snake case conversion.
Can generate decorators for interfaces from standard packages (e.g., io), third-party imports, or local relative paths, offering flexibility. Evidence: Usage examples in README show targeting io.Reader and ./connector packages.
Relies on internet access for initial use of hosted templates, and regeneration fails without connectivity unless templates are copied locally, adding setup complexity. Evidence: README warns about this and provides a workaround with gowrap template copy.
Exclusively works with Go interface types, making it ineffective for decorating struct methods or non-interface code, which can be restrictive in some architectures.
Creates additional files for each decorator, potentially increasing codebase size and compilation time, especially with many interfaces or nested decorations.