Skip to content

Latest commit

 

History

History
38 lines (26 loc) · 1.23 KB

README.md

File metadata and controls

38 lines (26 loc) · 1.23 KB

interfacegen

interfacegen is a utility to generate interfaces based on concrete types with methods.

It takes inspiration from vburenin/ifacemaker and rjeczalik/interfaces.

It leverages golang.org/x/tools/go/packages to parse packages, and optionally depends on go/ast for comments.

Its feature set is as follows:

  • Supports generating interfaces for all types with methods in a package
  • Supports copying comments from the source implementation into interfaces
  • Supports unique names for generated interfaces via -t concreteName,interfaceName
  • Correctly imports types defined in the source package
  • Supports //interfacegen:skip comments at the type and method level to selectively exclude items

Installation

go get github.com/Deiz/interfacegen

Usage

CLI

# Generate FooInterface from concrete type Foo
interfacegen -s github.com/your/package -t Foo:FooInterface

go generate

// Takes all types with methods in the current package and generates
// interfaces for them.
//go:generate interfacegen -s . -o interfaces/interfaces.go