From c4e4a5a089f9f89fdcca96c15f664e035a129bff Mon Sep 17 00:00:00 2001 From: Andrei Mihu Date: Sat, 23 Jan 2021 13:29:08 +0000 Subject: [PATCH] Clean up minor go vet issues. --- main.go | 3 ++- server/api_test.go | 2 +- server/console_authenticate.go | 4 ++-- server/runtime_lua_match_core.go | 1 + server/runtime_test.go | 2 +- 5 files changed, 7 insertions(+), 5 deletions(-) diff --git a/main.go b/main.go index d66ffd06c..35f92bba0 100644 --- a/main.go +++ b/main.go @@ -249,7 +249,8 @@ func dbConnect(multiLogger *zap.Logger, config server.Config) (*sql.DB, string) multiLogger.Fatal("Error connecting to database", zap.Error(err)) } // Limit the time allowed to ping database and get version to 15 seconds total. - ctx, _ := context.WithTimeout(context.Background(), 15*time.Second) + ctx, ctxCancelFn := context.WithTimeout(context.Background(), 15*time.Second) + defer ctxCancelFn() if err = db.PingContext(ctx); err != nil { if strings.HasSuffix(err.Error(), "does not exist (SQLSTATE 3D000)") { multiLogger.Fatal("Database schema not found, run `nakama migrate up`", zap.Error(err)) diff --git a/server/api_test.go b/server/api_test.go index 21b7beafa..1b3a1ea93 100644 --- a/server/api_test.go +++ b/server/api_test.go @@ -166,7 +166,7 @@ func NewAPIServer(t *testing.T, runtime *Runtime) (*ApiServer, *Pipeline) { db := NewDB(t) router := &DummyMessageRouter{} tracker := &LocalTracker{} - pipeline := NewPipeline(logger, cfg, db, jsonpbMarshaler, jsonpbUnmarshaler, nil, nil, nil, tracker, router, runtime) + pipeline := NewPipeline(logger, cfg, db, jsonpbMarshaler, jsonpbUnmarshaler, nil, nil, nil, nil, tracker, router, runtime) apiServer := StartApiServer(logger, logger, db, jsonpbMarshaler, jsonpbUnmarshaler, cfg, nil, nil, nil, nil, nil, nil, tracker, router, metrics, pipeline, runtime) return apiServer, pipeline } diff --git a/server/console_authenticate.go b/server/console_authenticate.go index 1ec13116d..f552f5f6b 100644 --- a/server/console_authenticate.go +++ b/server/console_authenticate.go @@ -29,7 +29,7 @@ import ( "google.golang.org/grpc/codes" "google.golang.org/grpc/status" - jwt "github.com/dgrijalva/jwt-go" + "github.com/dgrijalva/jwt-go" "github.com/heroiclabs/nakama/v3/console" ) @@ -38,7 +38,7 @@ type ConsoleTokenClaims struct { Email string `json:"ema,omitempty"` Role console.UserRole `json:"rol,omitempty"` ExpiresAt int64 `json:"exp,omitempty"` - Cookie string `json:"cki,omitempty""` + Cookie string `json:"cki,omitempty"` } func (stc *ConsoleTokenClaims) Valid() error { diff --git a/server/runtime_lua_match_core.go b/server/runtime_lua_match_core.go index 75d141723..676212f3f 100644 --- a/server/runtime_lua_match_core.go +++ b/server/runtime_lua_match_core.go @@ -111,6 +111,7 @@ func NewRuntimeLuaMatchCore(logger *zap.Logger, module string, db *sql.DB, jsonp if apiErr, ok := err.(*lua.ApiError); ok { if strings.Contains(apiErr.Error(), fmt.Sprintf("module %s not found", name)) { // Module not found + ctxCancelFn() return nil, nil } } diff --git a/server/runtime_test.go b/server/runtime_test.go index 128b81e7d..5b32a646b 100644 --- a/server/runtime_test.go +++ b/server/runtime_test.go @@ -354,7 +354,7 @@ nakama.register_rpc(test.printWorld, "helloworld")`, } db := NewDB(t) - pipeline := NewPipeline(logger, cfg, db, jsonpbMarshaler, jsonpbUnmarshaler, nil, nil, nil, nil, nil, runtime) + pipeline := NewPipeline(logger, cfg, db, jsonpbMarshaler, jsonpbUnmarshaler, nil, nil, nil, nil, nil, nil, runtime) apiServer := StartApiServer(logger, logger, db, jsonpbMarshaler, jsonpbUnmarshaler, cfg, nil, nil, nil, nil, nil, nil, nil, nil, metrics, pipeline, runtime) defer apiServer.Stop() -- GitLab