From a3fa670c3d7754a1d526c1849a493f3e091087f5 Mon Sep 17 00:00:00 2001 From: Stephen McQuay Date: Sat, 29 Mar 2014 01:24:20 -0700 Subject: [PATCH] Fixed scoping issue The bug here was that when you would try to start a game it would still be nil after the block where g was redefined. Just me being sloppy. --- control.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/control.go b/control.go index 795d19a..feb26bc 100644 --- a/control.go +++ b/control.go @@ -66,7 +66,8 @@ func (c *Controller) StartGame(w http.ResponseWriter, req *http.Request) { g := c.Games.get(requested_game_name) if g == nil { log.Printf("Game '%s' non-existant; making it now", requested_game_name) - g, err := NewGame(requested_game_name, width, height, obstacles, c.Conf.Tick, maxPoints, mode) + var err error + g, err = NewGame(requested_game_name, width, height, obstacles, c.Conf.Tick, maxPoints, mode) if err != nil { log.Printf("problem creating game: %s: %s", requested_game_name, err) b, _ := json.Marshal(NewFailure("game creation failure"))