From 0c981aa010d951395019f42f04d155b08a280c07 Mon Sep 17 00:00:00 2001 From: Hanzei <16541325+hanzei@users.noreply.github.com> Date: Thu, 31 Jan 2019 12:16:16 +0100 Subject: [PATCH] Prohibit variable shadowing (#10177) * Prohibit variable shadowing * Fix outstanding shadowed variables --- Makefile | 2 +- api4/post_test.go | 4 ++-- app/post_metadata.go | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 6da506db01..0600f9df33 100644 --- a/Makefile +++ b/Makefile @@ -290,7 +290,7 @@ clean-docker: ## Deletes the docker containers for local development. govet: ## Runs govet against all packages. @echo Running GOVET - $(GO) vet $(GOFLAGS) $(TE_PACKAGES) || exit 1 + $(GO) vet -shadow $(GOFLAGS) $(TE_PACKAGES) || exit 1 ifeq ($(BUILD_ENTERPRISE_READY),true) $(GO) vet $(GOFLAGS) $(EE_PACKAGES) || exit 1 diff --git a/api4/post_test.go b/api4/post_test.go index db5e49c396..5bd6f60af6 100644 --- a/api4/post_test.go +++ b/api4/post_test.go @@ -750,9 +750,9 @@ func TestPinPost(t *testing.T) { channel, err := th.App.GetChannelByName("town-square", th.BasicTeam.Id, true) assert.Nil(t, err) - post := th.CreatePostWithClient(th.SystemAdminClient, channel) + adminPost := th.CreatePostWithClient(th.SystemAdminClient, channel) - _, resp := Client.PinPost(post.Id) + _, resp = Client.PinPost(adminPost.Id) CheckForbiddenStatus(t, resp) }) diff --git a/app/post_metadata.go b/app/post_metadata.go index da61a8b76b..6816efbf0a 100644 --- a/app/post_metadata.go +++ b/app/post_metadata.go @@ -330,7 +330,7 @@ func (a *App) getLinkMetadata(requestURL string, timestamp int64, isNewPost bool // Check the database if this isn't a new post. If it is a new post and the data is cached, it should be in memory. if !isNewPost { - og, image, ok := a.getLinkMetadataFromDatabase(requestURL, timestamp) + og, image, ok = a.getLinkMetadataFromDatabase(requestURL, timestamp) if ok { cacheLinkMetadata(requestURL, timestamp, og, image)