How to build a map of struct and append values to it?
Example
package main
import "fmt"
type Emp struct {
x int
y []string
}
func main() {
var list = map[string]*Emp{"e1": {1001, []string{"John", "US"}}}
e := new(Emp)
e.x = 1002
e.y = []string{"Rock", "UK"}
list["e2"] = e
fmt.Println(list["e1"])
fmt.Println(list["e2"])
}
&{1001 [John US]}
&{1002 [Rock UK]}
Most Helpful This Week
Invalid memory address or nil pointer dereference error in Golang
Different ways for Integer to String Conversions
How do you handle HTTP client caching in Go?
Golang program for implementation LIFO Stack and FIFO Queue
Program in Go language to Program to Add Two Matrix Using Multi-dimensional Arrays
Interface embedding another interface in Go Programming Language