Skip to content

Commit

Permalink
readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Gamazic committed Feb 15, 2024
1 parent 7fb29c5 commit 3771939
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# stubgen

A Golang library for generating interface stubs.

## Installation

```shell
go install github.com/Gamazic/stubgen@latest
```

## Example

For example, we have go module with the following content:

`testfile.go`
```go
package main

type MyInterface interface {
Method(id int) error
}
```

To generate stub for the file use command with arg `--inp-file`:

```shell
go run stubgen --inp-file testdata/testfile.go
```

Result:

```go
type StubMyInterface struct {
AnotherFuncRes0 error
}

func (s StubMyInterface) AnotherFunc(_ int, _ bool) error {
return s.AnotherFuncRes0
}
```

Alternatively, you can provide source code from stdin:

```shell
cat testdata/testfile.go | go run stubgen
```

To save data in a file use the `--out-file` arg:

```shell
go run stubgen --inp-file testdata/testfile.go --out-file interface.go
```

0 comments on commit 3771939

Please sign in to comment.