-
Notifications
You must be signed in to change notification settings - Fork 17.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cmd/go: overview what type implements what interface in your program #33314
Comments
I think one way to mark your code as implementing an interface is by doing the following: import "fmt"
var _ fmt.GoStringer = (*S)(nil)
// S is a custom type.
type S struct {}
// GoString implements `fmt.GoStringer`.
func (s *S) GoString() string { return "" } You can then use the func Stringy(gs fmt.GoStringer) {
// ... code goes here ...
} You could also make such interface assertion statements just part of your test code that way it does not get compiled for the "release" version of your project. |
That's already a huge help thanks, still in addition a go vet type interface overview wouldn't hurt :P |
I've never used it, but this was mentioned in an issue (#33270) the other day: https://golang.org/lib/godoc/analysis/help.html. It looks like it's exactly what you're looking for. |
Your right the |
This sort of deep analysis is not really suited to |
Duplicate of #32973 |
It's frustrating for me when reading code you end up at a definition of a interface type used by a argument of a function but no idea which actual type in your program could have been passed that implemented that interface. Don't know if analysers are powerful enough to generate a overview of which type implements what interface in your program.
Is it possible to create a
go vet
orgo doc
analyser please that can generate this overview so I don't have to guess anymore or read tons of code to verify each type, thanks.The text was updated successfully, but these errors were encountered: