How to print interface in golang?
April 20, 2022Hi Friends 👋,
Welcome To aGuideHub! ❤️
Today, we will see how we can print an interface in the golang console, here we will use the fmt.Println()
method to show interface data in the golang console.
First, we have to create an interface with values which we pass in the fmt.Println()
method to console it.
Let’s dive into code…
package main
import "fmt"
func main() {
var x interface{} = []int{1, 2, 3}
fmt.Println(x)
}
Well, when you run above go program you will see array of int. check following image for output.
All the best 👍