Skip to content

Deiz/interfacegen

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Go interface generation from concrete types

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages