Skip to content

Instantly share code, notes, and snippets.

@mkock
Last active October 3, 2021 09:21
Show Gist options
  • Select an option

  • Save mkock/1a0c86ff7e204625a8bbeb18a061a118 to your computer and use it in GitHub Desktop.

Select an option

Save mkock/1a0c86ff7e204625a8bbeb18a061a118 to your computer and use it in GitHub Desktop.
type car struct {}
func (c *car) start() { return }
func (c *car) stop() { return }
type vehicle interface {
start()
stop()
}
func isCar(v vehicle) bool {
_, ok := v.(*car)
return ok
}
func main() {
var v = new(car)
fmt.Println(isCar(v)) // Prints "true"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment