@kjk1/

gobook interface type assertion 2

Go

No description

fork
loading
Files
  • main.go

This Plugin Crashed!

Error: Error: must not create an existing file {"type":"CREATE_FILE","wid":"0.6758317674852274","path":"main.go","file":{"path":"main.go","content":{"asEncoding":{"base64":"Ly8gYWxsb3cgZXJyb3IKcGFja2FnZSBtYWluCgppbXBvcnQgKAoJImZtdCIKKQoKLy8gOnNob3cgc3RhcnQKZnVuYyBwYW5pY09uSW52YWxpZENvbnZlcnNpb24oaXYgaW50ZXJmYWNle30pIHsKCXYgOj0gaXYuKGludCkKCWZtdC5QcmludGYoInYgaXMgaW50IG9mIHZhbHVlOiAlZFxuIiwgdikKfQoKZnVuYyBtYWluKCkgewoJcGFuaWNPbkludmFsaWRDb252ZXJzaW9uKCJzdHJpbmciKQp9CgovLyA6c2hvdyBlbmQ="},"asBuffer":null},"loaded":true}}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// allow error
package main

import (
	"fmt"
)

// :show start
func panicOnInvalidConversion(iv interface{}) {
	v := iv.(int)
	fmt.Printf("v is int of value: %d\n", v)
}

func main() {
	panicOnInvalidConversion("string")
}

// :show end