https://github.com/andrewstuart/impl
impl generates method stubs for implementing an interface.
https://github.com/andrewstuart/impl
Last synced: 5 months ago
JSON representation
impl generates method stubs for implementing an interface.
- Host: GitHub
- URL: https://github.com/andrewstuart/impl
- Owner: andrewstuart
- License: mit
- Fork: true (josharian/impl)
- Created: 2017-01-11T20:14:56.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-11-04T19:33:21.000Z (over 8 years ago)
- Last Synced: 2024-06-20T14:58:05.533Z (almost 2 years ago)
- Language: Go
- Size: 60.5 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
`impl` generates method stubs for implementing an interface.
```bash
go get -u github.com/josharian/impl
```
Sample usage:
```bash
$ impl 'f *File' io.ReadWriteCloser
func (f *File) Read(p []byte) (n int, err error) {
panic("not implemented")
}
func (f *File) Write(p []byte) (n int, err error) {
panic("not implemented")
}
func (f *File) Close() error {
panic("not implemented")
}
# You can also provide a full name by specifying the package path.
# This helps in cases where the interface can't be guessed
# just from the package name and interface name.
$ impl 's *Source' golang.org/x/oauth2.TokenSource
func (s *Source) Token() (*oauth2.Token, error) {
panic("not implemented")
}
# You can request that the declaring file be updated in-place by passing -u
$ impl -u 'f *File' io.ReadWriteCloser
# You can also specify a position at which you'd like the generated code to be
# inserted, helpful for editor/ide integration.
$ impl -p main.go:12 'f *File' io.ReadWriteCloser
# Finally, you can override the default stdout printing and send your output to
# a specific file with the -o option.
$ impl -p main.go:12 -o test/main2.go 'f *File' io.ReadWriteCloser
```
You can use `impl` from Vim with [vim-go-impl](https://github.com/rhysd/vim-go-impl)