1. package main
    2. import "fmt"
    3. func do(i interface{}) {
    4. switch v := i.(type) {
    5. fmt.Printf("Twice %v is %v\n", v, v*2)
    6. fmt.Printf("%q is %v bytes long\n", v, len(v))
    7. default:
    8. fmt.Printf("I don't know about type %T!\n", v)
    9. }
    10. func main() {
    11. do(21)
    12. do("hello")
    13. do(true)