From c464e0fe649c46b931578333b2ca31138175779a Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Mon, 16 Jul 2018 16:45:42 -0500 Subject: [PATCH] Fix linter issues: gofmt --- Makefile | 2 +- api.go | 44 ++++++++++++++-------------- cluster_internal_test.go | 16 +++++----- cmd/root_test.go | 2 +- field.go | 2 +- internal/test/querygenerator_test.go | 3 +- pql/parser_test.go | 4 +-- server/cluster_test.go | 2 +- 8 files changed, 37 insertions(+), 38 deletions(-) diff --git a/Makefile b/Makefile index 6c50a873f..1d3ca6780 100644 --- a/Makefile +++ b/Makefile @@ -109,7 +109,7 @@ docker-test: docker run --rm -v $(PWD):/go/src/$(CLONE_URL) -w /go/src/$(CLONE_URL) golang:$(GO_VERSION) go test -tags='$(BUILD_TAGS)' $(TESTFLAGS) ./... metalinter: - gometalinter --vendor --disable-all --enable=gotype --enable=gotypex --deadline=60s --exclude "^internal/.*\.pb\.go" ./... + gometalinter --vendor --disable-all --enable=gotype --enable=gotypex --enable=gofmt --deadline=60s --exclude "^internal/.*\.pb\.go" ./... ###################### # Build dependencies # diff --git a/api.go b/api.go index f646112b9..5dc7181d2 100644 --- a/api.go +++ b/api.go @@ -858,32 +858,32 @@ const ( ) var methodsCommon = map[apiMethod]struct{}{ - apiClusterMessage: struct{}{}, - apiSetCoordinator: struct{}{}, + apiClusterMessage: {}, + apiSetCoordinator: {}, } var methodsResizing = map[apiMethod]struct{}{ - apiResizeAbort: struct{}{}, + apiResizeAbort: {}, } var methodsNormal = map[apiMethod]struct{}{ - apiCreateField: struct{}{}, - apiCreateIndex: struct{}{}, - apiDeleteField: struct{}{}, - apiDeleteIndex: struct{}{}, - apiDeleteView: struct{}{}, - apiExportCSV: struct{}{}, - apiFragmentBlockData: struct{}{}, - apiFragmentBlocks: struct{}{}, - apiField: struct{}{}, - apiFieldAttrDiff: struct{}{}, - apiImport: struct{}{}, - apiImportValue: struct{}{}, - apiIndex: struct{}{}, - apiIndexAttrDiff: struct{}{}, - apiQuery: struct{}{}, - apiRecalculateCaches: struct{}{}, - apiRemoveNode: struct{}{}, - apiShardNodes: struct{}{}, - apiViews: struct{}{}, + apiCreateField: {}, + apiCreateIndex: {}, + apiDeleteField: {}, + apiDeleteIndex: {}, + apiDeleteView: {}, + apiExportCSV: {}, + apiFragmentBlockData: {}, + apiFragmentBlocks: {}, + apiField: {}, + apiFieldAttrDiff: {}, + apiImport: {}, + apiImportValue: {}, + apiIndex: {}, + apiIndexAttrDiff: {}, + apiQuery: {}, + apiRecalculateCaches: {}, + apiRemoveNode: {}, + apiShardNodes: {}, + apiViews: {}, } diff --git a/cluster_internal_test.go b/cluster_internal_test.go index 5b514e517..58b40ccbf 100644 --- a/cluster_internal_test.go +++ b/cluster_internal_test.go @@ -182,9 +182,9 @@ func TestFragSources(t *testing.T) { to: c2, idx: idx, expected: map[string][]*ResizeSource{ - "node0": []*ResizeSource{}, - "node1": []*ResizeSource{}, - "node2": []*ResizeSource{ + "node0": {}, + "node1": {}, + "node2": { {&Node{"node0", URI{"http", "host0", 10101}, false}, "i", "f", "standard", uint64(0)}, {&Node{"node1", URI{"http", "host1", 10101}, false}, "i", "f", "standard", uint64(2)}, }, @@ -196,10 +196,10 @@ func TestFragSources(t *testing.T) { to: c3, idx: idx, expected: map[string][]*ResizeSource{ - "node0": []*ResizeSource{ + "node0": { {&Node{"node1", URI{"http", "host1", 10101}, false}, "i", "f", "standard", uint64(1)}, }, - "node1": []*ResizeSource{ + "node1": { {&Node{"node0", URI{"http", "host0", 10101}, false}, "i", "f", "standard", uint64(0)}, {&Node{"node0", URI{"http", "host0", 10101}, false}, "i", "f", "standard", uint64(2)}, }, @@ -211,14 +211,14 @@ func TestFragSources(t *testing.T) { to: c4, idx: idx, expected: map[string][]*ResizeSource{ - "node0": []*ResizeSource{ + "node0": { {&Node{"node2", URI{"http", "host2", 10101}, false}, "i", "f", "standard", uint64(0)}, {&Node{"node2", URI{"http", "host2", 10101}, false}, "i", "f", "standard", uint64(2)}, }, - "node1": []*ResizeSource{ + "node1": { {&Node{"node0", URI{"http", "host0", 10101}, false}, "i", "f", "standard", uint64(3)}, }, - "node2": []*ResizeSource{}, + "node2": {}, }, err: "", }, diff --git a/cmd/root_test.go b/cmd/root_test.go index 20c4ec187..28bbea20d 100644 --- a/cmd/root_test.go +++ b/cmd/root_test.go @@ -158,7 +158,7 @@ func (ct *commandTest) setupCommand(t *testing.T) *cobra.Command { // reset the environment after setup/run of a commandTest. func (ct *commandTest) reset() { - for name, _ := range ct.env { + for name := range ct.env { os.Setenv(name, "") } } diff --git a/field.go b/field.go index a435148d3..a1bc17759 100644 --- a/field.go +++ b/field.go @@ -600,7 +600,7 @@ func (f *Field) viewNames() []string { defer f.mu.Unlock() other := make([]string, 0, len(f.viewMap)) - for viewName, _ := range f.viewMap { + for viewName := range f.viewMap { other = append(other, viewName) } return other diff --git a/internal/test/querygenerator_test.go b/internal/test/querygenerator_test.go index 7af764602..10a546630 100644 --- a/internal/test/querygenerator_test.go +++ b/internal/test/querygenerator_test.go @@ -1,11 +1,10 @@ package test import ( - "testing" "github.com/pilosa/pilosa/pql" + "testing" ) - func TestPQL_Generator(t *testing.T) { t.Run("pql.Query generator", func(t *testing.T) { for _, u := range []struct { diff --git a/pql/parser_test.go b/pql/parser_test.go index c7a260b92..b5d98fb13 100644 --- a/pql/parser_test.go +++ b/pql/parser_test.go @@ -47,8 +47,8 @@ func TestParser_Parse(t *testing.T) { &pql.Call{ Name: "Union", Children: []*pql.Call{ - &pql.Call{Name: "Bitmap"}, - &pql.Call{Name: "Count"}, + {Name: "Bitmap"}, + {Name: "Count"}, }, }, ) { diff --git a/server/cluster_test.go b/server/cluster_test.go index aff676ae0..9227a2b53 100644 --- a/server/cluster_test.go +++ b/server/cluster_test.go @@ -38,7 +38,7 @@ func TestMain_SendReceiveMessage(t *testing.T) { // Expected indexes and Fields expected := map[string][]string{ - "i": []string{"f"}, + "i": {"f"}, } // Create a client for each node.