interfacegen

command module
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2023 License: MIT Imports: 17 Imported by: 0

README

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

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

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