On Tuesday, October 9, 2012 8:35:21 AM UTC-10, Kamil Kisiel wrote:
> On Tuesday, October 9, 2012 8:14:28 AM UTC-7, jackman wrote:
>> Here is the code about which I speak:
>> http://pastebin.com/wSBfMAfN
>> The problem I am experiencing is that when I try to store a map into the
>> session, I get the following error:
>> securecookie: the value could not be encoded
>> The map I'm trying to assign to the session is as follows (with "%#v"):
>> map[string]int{"073366118239":1, "073366118238":2}
>> I've been beating my head against the wall trying to figure out why this
>> isn't working now, but it was earlier. I even have residual session data in
>> the same session. The only thing that I've changed recently is this line:
>> cart := make(map[string]int) // map[UPC]Quantity
>> It was originally just the following:
>> var cart map[string]int
>> Go was complaining about making assignments to a nil map.
>> I haven't changed the CookieStore key.
>> Here is the complete handler:
>> http://pastebin.com/bP6SvFRM
>> Thanks for all your help!
>> Andrew Jackman.
> Session uses securecookie to encode values in to the session. securecookie
> uses gob under the hood, the actual error is that your map type is not
> registered with gob.
> You need to make a function like:
> func init() {
> gob.Register(map[string]int{})
> }
> in your package to register your type with Gob. Unfortunately the reason
> it failed is unclear because of
> https://github.com/gorilla/securecookie/issues/1