Closed aacanakin closed 9 years ago
Thanks your feedback!
But the error seems incomplete?
http: panic serving [::1]:61196: session(start): gob: name not registered for interface:
Does the :
actually the last character or you didn't copy the error entirely?
After :
, there exists the model path of user model
I need details please, that may help!
Ok. Here's the full dump
http: panic serving [::1]:63107: session(start): gob: name not registered for interface: "_/Users/aacanakin/Desktop/dev/gocode/src/project/models.User"
goroutine 10 [running]:
net/http.func·011()
/usr/local/Cellar/go/1.4.2/libexec/src/net/http/server.go:1130 +0xbb
github.com/macaron-contrib/session.func·004(0xc20805d200)
/Users/aacanakin/Desktop/dev/gocode/src/github.com/macaron-contrib/session/session.go:158 +0x14d
reflect.Value.call(0x41a860, 0xc2080ebe60, 0x13, 0x582220, 0x4, 0xc20800b620, 0x1, 0x1, 0x0, 0x0, ...)
/usr/local/Cellar/go/1.4.2/libexec/src/reflect/value.go:419 +0x10e5
reflect.Value.Call(0x41a860, 0xc2080ebe60, 0x13, 0xc20800b620, 0x1, 0x1, 0x0, 0x0, 0x0)
/usr/local/Cellar/go/1.4.2/libexec/src/reflect/value.go:296 +0xbc
github.com/Unknwon/macaron/inject.(*injector).Invoke(0xc20800b540, 0x41a860, 0xc2080ebe60, 0x0, 0x0, 0x0, 0x0, 0x0)
/Users/aacanakin/Desktop/dev/gocode/src/github.com/Unknwon/macaron/inject/inject.go:102 +0x3c7
github.com/Unknwon/macaron.(*Context).run(0xc20805d200)
/Users/aacanakin/Desktop/dev/gocode/src/github.com/Unknwon/macaron/context.go:113 +0x95
github.com/Unknwon/macaron.func·015(0x938c30, 0xc208045720, 0xc20801fd40, 0xc20803dd70)
/Users/aacanakin/Desktop/dev/gocode/src/github.com/Unknwon/macaron/router.go:183 +0x3ec
github.com/Unknwon/macaron.(*Router).ServeHTTP(0xc208041f90, 0x938c30, 0xc208045720, 0xc20801fd40)
/Users/aacanakin/Desktop/dev/gocode/src/github.com/Unknwon/macaron/router.go:271 +0x1ab
github.com/Unknwon/macaron.(*Macaron).ServeHTTP(0xc2080ec0e0, 0x938c30, 0xc208045720, 0xc20801fd40)
/Users/aacanakin/Desktop/dev/gocode/src/github.com/Unknwon/macaron/macaron.go:171 +0x17c
net/http.serverHandler.ServeHTTP(0xc20805b2c0, 0x938c30, 0xc208045720, 0xc20801fd40)
/usr/local/Cellar/go/1.4.2/libexec/src/net/http/server.go:1703 +0x19a
net/http.(*conn).serve(0xc2080455e0)
/usr/local/Cellar/go/1.4.2/libexec/src/net/http/server.go:1204 +0xb57
created by net/http.(*Server).Serve
/usr/local/Cellar/go/1.4.2/libexec/src/net/http/server.go:1751 +0x35e
This happens if I don't cleanup sessions folder and start the web server
Hi @aacanakin , thanks your info! I've pushed some changes, please use go get -u github.com/macaron-contrib/session
and rebuild your program see if problem is being solved!
Hi @Unknwon. The problem continues.
I looked at your commit. Before starting the app and registering the session middleware, If I add the following line; the problem is fixed;
gob.Register(models.User{})
But I think this is not an out of the box solution
@aacanakin thanks for the tip!
Did some researching, it seems no way to know what types are inside gob encoded data and register automatically.
In your case and other similar cases, I think user have to do:
func init() {
gob.Register(&models.User{})
}
This way, gob knows how decode it.
Ok then, I'm closing this. Thanks.
@aacanakin sorry about it, maybe someday comes up a better way to encode data into binary, or should just store user ID in session and it's fast to read user info by ID from database.
Hello, When I start the web server using macaron, if the session store is empty, there is no problem in setting structs to user; Here's the model;
When I first run
sess.Set("user", user)
it saves with no errors. However, If I close the web server and open againsess.Set()
it shows the following error;It seems like I need to register some kind of struct metadata to gob. This issue is present whether I use folder session store or mysql.
Are there any solutions to that?