mirror of
https://github.com/MADTeacher/go_basics.git
synced 2025-11-23 21:34:47 +02:00
24 lines
321 B
Go
24 lines
321 B
Go
package main
|
|
|
|
import "fmt"
|
|
|
|
type shape struct{}
|
|
type car struct{}
|
|
|
|
func checkType(i interface{}) {
|
|
switch i.(type) {
|
|
case shape:
|
|
fmt.Println("It is shape")
|
|
case car:
|
|
fmt.Println("It is car")
|
|
default:
|
|
fmt.Println("What is this pokemon?")
|
|
}
|
|
}
|
|
|
|
func main() {
|
|
checkType(shape{})
|
|
checkType(car{})
|
|
checkType(6)
|
|
}
|