Skip to content

Commit

Permalink
Adding goimports support to make check and fmt (#4114)
Browse files Browse the repository at this point in the history
  • Loading branch information
vjsamuel authored and ruflin committed Apr 26, 2017
1 parent dce6887 commit a279b5d
Show file tree
Hide file tree
Showing 13 changed files with 30 additions and 16 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ https://github.com/elastic/beats/compare/v5.1.1...master[Check the HEAD diff]
- Add kubernetes processor {pull}3888[3888]
- Add support for include_labels and include_annotations in kubernetes processor {pull}4043[4043]
- Support new `index_patterns` field when loading templates for Elasticsearch >= 6.0 {pull}4056[4056]
- Adding goimports support to make check and fmt {pull}4114[4114]

*Filebeat*

Expand Down
3 changes: 2 additions & 1 deletion filebeat/processors/kubernetes/indexing_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ package kubernetes

import (
"fmt"
"testing"

"github.com/elastic/beats/libbeat/common"
"github.com/stretchr/testify/assert"
"testing"
)

func TestLogsPathMatcher(t *testing.T) {
Expand Down
3 changes: 2 additions & 1 deletion libbeat/processors/kubernetes/config.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package kubernetes

import (
"github.com/elastic/beats/libbeat/common"
"time"

"github.com/elastic/beats/libbeat/common"
)

type kubeAnnotatorConfig struct {
Expand Down
9 changes: 6 additions & 3 deletions libbeat/scripts/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ COVERAGE_DIR=${BUILD_DIR}/coverage
COVERAGE_TOOL=${BEAT_GOPATH}/bin/gotestcover
COVERAGE_TOOL_REPO=github.com/elastic/beats/vendor/github.com/pierrre/gotestcover
TESTIFY_TOOL_REPO=github.com/elastic/beats/vendor/github.com/stretchr/testify
GOIMPORTS=goimports
GOIMPORTS_REPO=golang.org/x/tools/cmd/goimports
GOLINT=golint
GOLINT_REPO=github.com/golang/lint/golint
REVIEWDOG=reviewdog -conf ${ES_BEATS}/reviewdog.yml
Expand Down Expand Up @@ -93,13 +95,14 @@ crosscompile: $(GOFILES)

.PHONY: check
check: python-env ## @build Checks project and source code if everything is according to standard
@gofmt -l ${GOFILES_NOVENDOR} | (! grep . -q) || (echo "Code differs from gofmt's style" && false)
go vet ${GOPACKAGES}
@go get $(GOIMPORTS_REPO)
@goimports -l ${GOFILES_NOVENDOR} | (! grep . -q) || (echo "Code differs from goimports' style" && false)
${FIND} -name *.py -exec autopep8 -d --max-line-length 120 {} \; | (! grep . -q) || (echo "Code differs from autopep8's style" && false)

.PHONY: fmt
fmt: python-env ## @build Runs `gofmt -s -l -w` and `autopep8`on the project's source code, modifying any files that do not match its style.
gofmt -s -l -w ${GOFILES_NOVENDOR}
fmt: python-env ## @build Runs `goimports -l -w` and `autopep8`on the project's source code, modifying any files that do not match its style.
goimports -l -w ${GOFILES_NOVENDOR}
${FIND} -name *.py -exec autopep8 --in-place --max-line-length 120 {} \;

.PHONY: lint
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ package cluster_disk

import (
"fmt"
mbtest "github.com/elastic/beats/metricbeat/mb/testing"
"os"
"testing"

mbtest "github.com/elastic/beats/metricbeat/mb/testing"
)

func TestData(t *testing.T) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ package pool_disk

import (
"fmt"
mbtest "github.com/elastic/beats/metricbeat/mb/testing"
"os"
"testing"

mbtest "github.com/elastic/beats/metricbeat/mb/testing"
)

func TestData(t *testing.T) {
Expand Down
5 changes: 3 additions & 2 deletions metricbeat/module/docker/image/data.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package image

import (
"github.com/elastic/beats/libbeat/common"
"time"

"github.com/elastic/beats/libbeat/common"
"github.com/elastic/beats/metricbeat/module/docker"

dc "github.com/fsouza/go-dockerclient"
"time"
)

func eventsMapping(imagesList []dc.APIImages) []common.MapStr {
Expand Down
3 changes: 2 additions & 1 deletion metricbeat/module/dropwizard/collector/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ package collector

import (
"encoding/json"
"strings"

"github.com/elastic/beats/libbeat/common"
"github.com/elastic/beats/libbeat/logp"
"github.com/elastic/beats/metricbeat/helper"
"github.com/elastic/beats/metricbeat/mb"
"github.com/elastic/beats/metricbeat/mb/parse"
"strings"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion metricbeat/module/dropwizard/collector/data.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package collector

import (
"encoding/json"
"strings"

"encoding/json"
"github.com/elastic/beats/libbeat/common"
)

Expand Down
3 changes: 2 additions & 1 deletion metricbeat/module/golang/heap/heap.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ package heap

import (
"encoding/json"
"runtime"

"github.com/elastic/beats/libbeat/common"
"github.com/elastic/beats/libbeat/logp"
"github.com/elastic/beats/metricbeat/helper"
"github.com/elastic/beats/metricbeat/mb"
"github.com/elastic/beats/metricbeat/mb/parse"
"github.com/elastic/beats/metricbeat/module/golang"
"runtime"
)

const (
Expand Down
3 changes: 2 additions & 1 deletion metricbeat/module/golang/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ package golang

import (
"bytes"
"github.com/elastic/beats/libbeat/logp"
"strings"

"github.com/elastic/beats/libbeat/logp"
)

/**
Expand Down
5 changes: 3 additions & 2 deletions packetbeat/protos/cassandra/internal/gocql/frame.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ package cassandra
import (
"errors"
"fmt"
"github.com/elastic/beats/libbeat/common/streambuf"
"github.com/elastic/beats/libbeat/logp"
"runtime"
"sync"

"github.com/elastic/beats/libbeat/common/streambuf"
"github.com/elastic/beats/libbeat/logp"
)

var (
Expand Down
3 changes: 2 additions & 1 deletion packetbeat/protos/nfs/config.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package nfs

import (
"github.com/elastic/beats/packetbeat/config"
"time"

"github.com/elastic/beats/packetbeat/config"
)

type rpcConfig struct {
Expand Down

0 comments on commit a279b5d

Please sign in to comment.