go-gen-interface

command module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2022 License: MIT Imports: 4 Imported by: 0

README

Go Gen Interface: Simple Go Interface Generator

Generate Go interfaces from structs and their methods.

// FROM THIS
package example

type A struct{}

func (a *A) FuncA(i1 int, i2 string) {
	panic("not implemented")
}

func (a *A) FuncB() (int, error) {
	panic("not implemented")
}

// TO THIS
type A interface {
	FuncA(i1 int, i2 string)
	FuncB() (int, error)
}

Installation

go get github.com/siraphobk/go-gen-interface

Usage

go run github.com/siraphobk/go-gen-interface [COMMAND] [FLAGS]...

Interface Generation

The program reads a directory of Go files. It finds all structs and their methods, then generate an interface of those structs. Interface generator is a CLI program. You can see all the available commands and flags by running go run main.go --help.

Examples

Generate interfaces from structs

Run make run_example, then see result in example/gen-interface.

Initialize configuration file for interface generation

Run make run_example_init, then see result in example/gen-interface-init.

Roadmap

  • Interface generator reads configuration from config file
  • Allow adding prefix and suffix to interfaces
  • Implement struct generator

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
_example

Jump to

Keyboard shortcuts

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