. Advertisement .
..3..
Hello everyone! I’m learning about String. Does anyone have a specific syntax or example of “String To Interface Golang”?
♦ Suggestions of ITtutoria Team
Ideas for “String To Interface Golang”: The string to interface golang tool converts any string of text from and to a more user-friendly JSON object that includes an array of dictionaries containing the name, value, type, and key for each field. In this case, make use of fmt.Sprintf to transform an unicode string into the Interface value. As you know, Sprintf formattes according to a format specifier , and produces the resultant string. Here is example:
var x interface{} = []int{1, 2, 3}
str1 := fmt.Sprintf("%v", x)
str2 := x.(string)
fmt.Println(str1)
fmt.Println(str2)
It seems this solution works, you may try it
I would do something like this