https://github.com/hankjacobs/gointerfacegen
Go tool for generating interfaces from a type
https://github.com/hankjacobs/gointerfacegen
go golang interface tool
Last synced: 11 months ago
JSON representation
Go tool for generating interfaces from a type
- Host: GitHub
- URL: https://github.com/hankjacobs/gointerfacegen
- Owner: hankjacobs
- Created: 2018-01-02T05:38:43.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-01-02T06:08:26.000Z (over 8 years ago)
- Last Synced: 2025-02-15T11:32:41.263Z (over 1 year ago)
- Topics: go, golang, interface, tool
- Language: Go
- Size: 4.88 KB
- Stars: 4
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# gointerfacegen
A Go tool used to generate an interface from a type's methods.
## Installation
```bash
go get github.com/hankjacobs/gointerfacegen
```
## Usage
```text
gointefacegen
Generates an interface from the type's methods found in the specified file. File must be valid go source.
If the interface already exists, it is updated in place.
Default behavior prints the resulting file with the new or updated interface to standard out.
Examples:
gointefacegen somecustomtype somecustominterface src.go
-i Print only interface to standard out. This takes precedence over -w flag
-w Write result to file instead of stdout
```
## Example
Given a file `demo.go`:
```go
package demo
type example struct {
}
func (t example) First() {
}
func (t example) Second(one, two string) (named example, other example) {
return
}
```
running:
```shell
gointerfacegen example ExampleInterface demo.go
```
will produce:
```go
package demo
type ExampleInterface interface {
First()
Second(one, two string) (example, example)
}
type example struct {
}
func (t example) First() {
}
func (t example) Second(one, two string) (named example, other example) {
return
}
```