string to interface golang code example
Example 1: interface to string golang
var x interface{} = "abc"
str := fmt.Sprintf("%v", x)
Example 2: interface to string in golang
var x interface{} = []int{1, 2, 3}
str1 := fmt.Sprintf("%v", x)
str2 := x.(string)
fmt.Println(str1)
fmt.Println(str2)
Example 3: interface to int golang
iAreaId := val.(int)
iAreaId, ok := val.(int) // Alt. non panicking version