Skip to content

magdyamr542/interface-inspector

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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
    │   │   └── facebook.go
    │   └── fetcher
    │   └── fetcher.go
    └── README.md
    
    
    // file: pkg/fetcher/fetcher.go
    package fetcher
    type Fetcher interface {
    	Fetch (url string) ([]byte , error)
    }
    // file: pkg/aws/aws.go
    package aws
    type awsFetcher struct {
    }
    func (a *awsFetcher) Fetch (url string) ([]byte , error) {
    	return nil , nil
    }
    // 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.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages