https://github.com/magdyamr542/interface-inspector
https://github.com/magdyamr542/interface-inspector
Last synced: 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/magdyamr542/interface-inspector
- Owner: magdyamr542
- Created: 2023-02-11T21:59:48.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-02-12T22:28:51.000Z (over 2 years ago)
- Last Synced: 2025-07-22T11:03:09.190Z (3 months ago)
- Language: Go
- Size: 8.79 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Interface inspector
See which `structs` implement a given `interface`.
#### Example:
- Given the following project structure, we have an interface `Fetcher` which is implemented by both the `awsFetcher struct` and `facebookFetcher` struct.
- Running `interface-inspector -package fetcher -interface Fetcher` would output all structs which implement the interface **Fetcher** defined in the package named **fetcher**.
- Output example:
```
awsFetcher /home/tester/Documents/projects/interface-inspector/pkg/aws/aws.go:3:6
facebookFetcher /home/tester/Documents/projects/interface-inspector/pkg/facebook/facebook.go:3:6
```
- Clicking with the mouse on the path in the output in an editor like `VSCode` would open the strcut directly which is handy in big projects where a lot of structs implement an interface and one wants to see all of them.```
├── go.mod
├── go.sum
├── main.go
├── pkg
│ ├── aws
│ │ └── aws.go
│ │ └── facebook.go
│ └── fetcher
│ └── fetcher.go
└── README.md```
```go
// file: pkg/fetcher/fetcher.go
package fetcher
type Fetcher interface {
Fetch (url string) ([]byte , error)
}
``````go
// file: pkg/aws/aws.go
package aws
type awsFetcher struct {
}
func (a *awsFetcher) Fetch (url string) ([]byte , error) {
return nil , nil
}
``````go
// file: pkg/facebook/facebook.go
package facebook
type facebookFetcher struct {
}
func (a *facebookFetcher) Fetch (url string) ([]byte , error) {
return nil , nil
}
```#### Usage:
- Run `interface-inspector -h`
#### TODOS:
- Write a VSCode extension to interface with this. the extension should return the output in something like a quickpick list similar to what vscode does with the output of the language server.