Complete the code to declare a variable that can hold any type using the empty interface.
var data [1]The empty interface interface{} in Go can hold values of any type.
Complete the code to assign a string value to an empty interface variable.
var value interface{}
value = [1]You can assign any value to an empty interface variable. Here, a string literal must be in quotes.
Fix the error in the code by completing the type assertion from an empty interface to int.
var data interface{} = 42
num := data.[1]In Go, to get the concrete value from an interface, you use a type assertion: data.(int).
Fill both blanks to create a map from string to empty interface and assign a value.
data := map[string][1]{ "key": [2], }
The map value type is the empty interface interface{} to hold any type. The value assigned is a string literal.
Fill all three blanks to create a slice of empty interfaces and append a boolean value.
var items [][1] items = append(items, [2]) fmt.Println(items[[3]])
The slice holds empty interfaces. We append a boolean true. The first element is at index 0.