Support custom type?
7hamsbon opened this issue · comments
7hamsbon commented
Hi, respect your work. I wonder if is this tool support detect custom type which implement interface or not?
Sina Siadat commented
Thank you @7hamsbon! :)
I didn't exactly understand what you meant, but it does sound interesting and I'm curious. If you write an example (code or pseudo code) that would be super cool :)
I thought you mean something like the Q case in this example: (this scenario is already checked by the Go compiler)
package main
type I interface {
Do()
}
type T struct{}
func (T) Do() {}
type Q struct{}
func run(i I) {
switch i.(type) {
case T: // OK
case Q: // ERROR: impossible type switch case
}
}
func main() {
run(T{})
}
Playground link: https://play.golang.org/p/D01LcFY3-rV