implgen

command module
v1.5.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 8, 2025 License: Apache-2.0 Imports: 10 Imported by: 0

README

implgen

Go License

implgen is a developer utility designed to automatically generate boilerplate implementations for Go interfaces. It helps kick-start the development of service layers, adapters, and stubs while saving time and reducing manual effort.


Overview

implgen provides some fetures:

  • 🛠 Generate empty implementations of interfaces
  • 📂 Supports single-file or per-method file output
  • 📦 Customizable output package and struct name
  • 🎯 Target a specific interface or process all in the source file
  • 🐫 Automatic file/folder naming via kebab-case and snake_case converters

🚀 Installation

go install github.com/not-for-prod/implgen@latest

Usage example

implgen --src=./service --dst=./serviceimpl --interface-name=Greeter

Flags (required):

  • src - source file path
  • dst - destination dir path

Flags (optional):

  • interface-name - source interface name
  • impl-name - generated implementation struct name
  • impl-package - generated implementation package name, can be used only if interface-name set
  • enable-trace - enables writing otel.Traсer(...).Start(...) in methods,

Assume you have an interface:

type TestInterface interface {
    A(ctx context.Context, req dto.GoRequest) error
    B(ctx context.Context, req map[dto.GoRequest]dto.GoRequest) error
    C(ctx context.Context, req []dto.GoRequest) error
    D(ctx context.Context, req int, opts ...dto.GoRequest) error
}

Run:

implgen --src example/in/interface.go \
		--dst example/out/ \
		--interface-name TestInterface \
		--impl-name Test \
		--impl-package test

This will generate:

  • A struct with name Test with method stubs

See dst example for more details

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
example
in
pkg

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL