From d18a122ad7b5ad3f358b33a619b212250988a431 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Cuadrado=20Juan?= Date: Thu, 21 Feb 2019 11:58:24 +0100 Subject: [PATCH] Fix shadowed variables as prompted by go lint/vet --- .../matrix-org/go-neb/clients/clients.go | 2 +- src/github.com/matrix-org/go-neb/goneb.go | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/github.com/matrix-org/go-neb/clients/clients.go b/src/github.com/matrix-org/go-neb/clients/clients.go index bd850a4..6b3baf4 100644 --- a/src/github.com/matrix-org/go-neb/clients/clients.go +++ b/src/github.com/matrix-org/go-neb/clients/clients.go @@ -129,7 +129,7 @@ func (c *Clients) updateClientInDB(newConfig api.ClientConfig) (new clientEntry, // set the new display name if they differ if old.config.DisplayName != new.config.DisplayName { - if err := new.client.SetDisplayName(new.config.DisplayName); err != nil { + if err = new.client.SetDisplayName(new.config.DisplayName); err != nil { // whine about it but don't stop: this isn't fatal. log.WithFields(log.Fields{ log.ErrorKey: err, diff --git a/src/github.com/matrix-org/go-neb/goneb.go b/src/github.com/matrix-org/go-neb/goneb.go index 6afcb56..b1bcbdc 100644 --- a/src/github.com/matrix-org/go-neb/goneb.go +++ b/src/github.com/matrix-org/go-neb/goneb.go @@ -172,15 +172,15 @@ func setup(e envVars, mux *http.ServeMux, matrixClient *http.Client) { log.Info("Inserted ", len(cfg.Sessions), " sessions") } - clients := clients.New(db, matrixClient) - if err := clients.Start(); err != nil { + matrixClients := clients.New(db, matrixClient) + if err := matrixClients.Start(); err != nil { log.WithError(err).Panic("Failed to start up clients") } // Handle non-admin paths for normal NEB functioning mux.Handle("/metrics", prometheus.Handler()) mux.Handle("/test", prometheus.InstrumentHandler("test", util.MakeJSONAPI(&handlers.Heartbeat{}))) - wh := handlers.NewWebhook(db, clients) + wh := handlers.NewWebhook(db, matrixClients) mux.HandleFunc("/services/hooks/", prometheus.InstrumentHandlerFunc("webhookHandler", util.Protect(wh.Handle))) rh := &handlers.RealmRedirect{db} mux.HandleFunc("/realms/redirects/", prometheus.InstrumentHandlerFunc("realmRedirectHandler", util.Protect(rh.Handle))) @@ -188,7 +188,7 @@ func setup(e envVars, mux *http.ServeMux, matrixClient *http.Client) { // Read exclusively from the config file if one was supplied. // Otherwise, add HTTP listeners for new Services/Sessions/Clients/etc. if e.ConfigFile != "" { - if err := insertServicesFromConfig(clients, cfg.Services); err != nil { + if err := insertServicesFromConfig(matrixClients, cfg.Services); err != nil { log.WithError(err).Panic("Failed to insert services") } @@ -196,13 +196,13 @@ func setup(e envVars, mux *http.ServeMux, matrixClient *http.Client) { } else { mux.Handle("/admin/getService", prometheus.InstrumentHandler("getService", util.MakeJSONAPI(&handlers.GetService{db}))) mux.Handle("/admin/getSession", prometheus.InstrumentHandler("getSession", util.MakeJSONAPI(&handlers.GetSession{db}))) - mux.Handle("/admin/configureClient", prometheus.InstrumentHandler("configureClient", util.MakeJSONAPI(&handlers.ConfigureClient{clients}))) - mux.Handle("/admin/configureService", prometheus.InstrumentHandler("configureService", util.MakeJSONAPI(handlers.NewConfigureService(db, clients)))) + mux.Handle("/admin/configureClient", prometheus.InstrumentHandler("configureClient", util.MakeJSONAPI(&handlers.ConfigureClient{matrixClients}))) + mux.Handle("/admin/configureService", prometheus.InstrumentHandler("configureService", util.MakeJSONAPI(handlers.NewConfigureService(db, matrixClients)))) mux.Handle("/admin/configureAuthRealm", prometheus.InstrumentHandler("configureAuthRealm", util.MakeJSONAPI(&handlers.ConfigureAuthRealm{db}))) mux.Handle("/admin/requestAuthSession", prometheus.InstrumentHandler("requestAuthSession", util.MakeJSONAPI(&handlers.RequestAuthSession{db}))) mux.Handle("/admin/removeAuthSession", prometheus.InstrumentHandler("removeAuthSession", util.MakeJSONAPI(&handlers.RemoveAuthSession{db}))) } - polling.SetClients(clients) + polling.SetClients(matrixClients) if err := polling.Start(); err != nil { log.WithError(err).Panic("Failed to start polling") }