When performing stress testing, I found that concurrent session writes raised an error:
fatal error: concurrent map writes
goroutine 103 [running]:
runtime.throw(0x8bfbf0, 0x15)
/usr/lib/go/src/runtime/panic.go:530 +0x90 fp=0xc8201735a8 sp=0xc820173590
runtime.mapassign1(0x742fc0, 0xc820011590, 0xc8201736b0, 0xc820173680)
/usr/lib/go/src/runtime/hashmap.go:445 +0xb1 fp=0xc820173650 sp=0xc8201735a8
github.com/dinever/golf.(*MemorySessionManager).NewSession(0xc820026058, 0x0, 0x0, 0x0, 0x0)
/home/ubuntu/go/src/github.com/dinever/golf/session.go:54 +0x19c fp=0xc8201736e0 sp=0xc820173650
github.com/dinever/golf.(*Context).generateSession(0xc8206d2200, 0x0, 0x0)
/home/ubuntu/go/src/github.com/dinever/golf/context.go:63 +0x58 fp=0xc820173758 sp=0xc8201736e0
github.com/dinever/golf.(*Context).retrieveSession(0xc8206d2200)
/home/ubuntu/go/src/github.com/dinever/golf/context.go:76 +0x88 fp=0xc8201737d8 sp=0xc820173758
github.com/dinever/golf.(*Application).handler(0xc820070550, 0xc8206d2200)
/home/ubuntu/go/src/github.com/dinever/golf/app.go:75 +0x489 fp=0xc820173990 sp=0xc8201737d8
github.com/dinever/golf.(*Application).(github.com/dinever/golf.handler)-fm(0xc8206d2200)
/home/ubuntu/go/src/github.com/dinever/golf/app.go:91 +0x2a fp=0xc8201739a8 sp=0xc820173990
github.com/dinever/golf.XSRFProtectionMiddleware.func1(0xc8206d2200)
/home/ubuntu/go/src/github.com/dinever/golf/middleware.go:61 +0x150 fp=0xc820173a10 sp=0xc8201739a8
github.com/dinever/golf.RecoverMiddleware.func1(0xc8206d2200)
/home/ubuntu/go/src/github.com/dinever/golf/middleware.go:84 +0x56 fp=0xc820173a38 sp=0xc820173a10
github.com/dinever/golf.LoggingMiddleware.func1(0xc8206d2200)
/home/ubuntu/go/src/github.com/dinever/golf/middleware.go:44 +0x67 fp=0xc820173b30 sp=0xc820173a38
github.com/dinever/golf.(*Application).ServeHTTP(0xc820070550, 0x7f5cff26c890, 0xc820057110, 0xc82070e7e0)
/home/ubuntu/go/src/github.com/dinever/golf/app.go:91 +0xc2 fp=0xc820173b70 sp=0xc820173b30
net/http.serverHandler.ServeHTTP(0xc820054500, 0x7f5cff26c890, 0xc820057110, 0xc82070e7e0)
/usr/lib/go/src/net/http/server.go:2081 +0x19e fp=0xc820173bd0 sp=0xc820173b70
net/http.(*conn).serve(0xc8204cce00)
/usr/lib/go/src/net/http/server.go:1472 +0xf2e fp=0xc820173f98 sp=0xc820173bd0
runtime.goexit()
/usr/lib/go/src/runtime/asm_amd64.s:1998 +0x1 fp=0xc820173fa0 sp=0xc820173f98
created by net/http.(*Server).Serve
/usr/lib/go/src/net/http/server.go:2137 +0x44e
I think we need to add something like a mutex on the in MemorySessionManager.NewSession
to fix this.