xxxxxxxxxx
// create an empty interface
var a interface {}
// store value of string type
a = "Hello World"
// store value of integer type
a = 10
xxxxxxxxxx
// assertedVariable, ok := variable.(type)
var foo interface{} = "Hello"
str := foo.(string)
fmt.Println(str) // "Hello"
num := foo.(int) // panic
fmt.Println(num)
num2, ok := foo.(int)
fmt.Println(num2, ok) // 0, false
xxxxxxxxxx
package main
import "fmt"
func main() {
// create an empty interface
var a interface {}
// store integer to an empty interface
a = 10
// type assertion
interfaceValue := a.(int)
fmt.Println(interfaceValue)
}