Skip to content

Convert Interface to String

We can use the %v formatting directive with Sprintf to convert the interface:

var a interface{} = "hello world"
b := fmt.Sprintf("%v", a)
fmt.Println(b)

https://pkg.go.dev/fmt#Sprintf

Back to top