Could someone help,
I am trying to itreate over an interface and fetch the "id" and "name" in
below code,
is there a better way to do this.
package main
import (
"fmt"
)
type product struct {
id int
name string
}
func main(){
fmt.Println("Hello ALLTEST")
p := product{id : 12, name:"apple"}
c := product{id : 13, name:"samsung"}
var pslice []product
pslice = append(pslice, p)
pslice = append(pslice, c)
d := map[string]interface{}{
"allproducts" : pslice,
}
f:= d["allproducts"]
fmt.Println("Output", f)
--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/golang-nuts/efc07073-25d5-463b-9b98-9fdcf015c944n%40googlegroups.com.