This is a creation in Article, where the information may have evolved or changed.
Recently the company project, changed to Golang below to develop, met the problem of Redis storage chain list, troubled me for a few days, back to the heart, read a bit of source code, found the official example, and finally the wool out of the sheep
C, Err: =dial ()ifErr! =Nil {panic (err)} defer c.close ()varP1, p2 struct {Title string ' Redis:"Title"' Author string ' Redis:"Author"' Body string ' Redis:"Body"'} p1. Title= "Example"P1. Author= "Gary"P1. Body= "Hello"if_, Err: = C.do ("Hmset", Redis. args{}. ADD ("Id1"). Addflat (&P1) ...); Err! =Nil {panic (err)} m:=map[string]string{"title": "Example2", "Author": "Steve", "Body": "Map", } if_, Err: = C.do ("Hmset", Redis. args{}. ADD ("Id2"). Addflat (m) ...); Err! =Nil {panic (err)} for_, id: = range []string{"Id1", "Id2"} {V, err:= Redis. Values (C.do ("Hgetall", id)) ifErr! =Nil {panic (err)}ifERR: = Redis. Scanstruct (V, &P2); Err! =Nil {panic (err)} FMT. Printf ("%+v\n", p2)}