1
0
Fork 0
This commit is contained in:
Alex Kotov 2020-11-17 09:06:29 +05:00
parent 6a315ca521
commit b2fb9c90d4
Signed by: kotovalexarian
GPG key ID: 553C0EBBEB5D5F08
2 changed files with 21 additions and 0 deletions

View file

@ -0,0 +1,2 @@
all:
go run main.go

View file

@ -0,0 +1,19 @@
package main
import "fmt"
func main() {
var i interface{} = "hello"
s := i.(string)
fmt.Println(s)
s, ok := i.(string)
fmt.Println(s, ok)
f, ok := i.(float64)
fmt.Println(f, ok)
f = i.(float64) // panic
fmt.Println(f)
}