Skip to content

Commit

Permalink
Add goimports check and fix import order for all files
Browse files Browse the repository at this point in the history
  • Loading branch information
songy23 committed Jul 30, 2019
1 parent e87131c commit 28bf4bd
Show file tree
Hide file tree
Showing 10 changed files with 47 additions and 22 deletions.
24 changes: 19 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ GOTEST_OPT?= -race -timeout 30s
GOTEST_OPT_WITH_COVERAGE = $(GOTEST_OPT) -coverprofile=coverage.txt -covermode=atomic
GOTEST=go test
GOFMT=gofmt
GOIMPORTS=goimports
GOLINT=golint
GOVET=go vet
GOOS=$(shell go env GOOS)
Expand All @@ -32,8 +33,8 @@ all-srcs:

.DEFAULT_GOAL := addlicense-fmt-vet-lint-test

.PHONY: addlicense-fmt-vet-lint-test
addlicense-fmt-vet-lint-test: addlicense fmt vet lint test
.PHONY: addlicense-fmt-vet-lint-goimports-test
addlicense-fmt-vet-lint-goimports-test: addlicense fmt vet lint goimports test

.PHONY: e2e-test
e2e-test: otelsvc
Expand All @@ -44,7 +45,7 @@ test:
$(GOTEST) $(GOTEST_OPT) $(ALL_PKGS)

.PHONY: travis-ci
travis-ci: fmt vet lint test-with-cover otelsvc
travis-ci: fmt vet lint goimports test-with-cover otelsvc
$(MAKE) -C testbed install-tools
$(MAKE) -C testbed runtests

Expand Down Expand Up @@ -90,15 +91,28 @@ lint:
echo "Lint finished successfully"; \
fi

.PHONY: goimports
goimports:
@IMPORTSOUT=`$(GOIMPORTS) -l . 2>&1`; \
if [ "$$IMPORTSOUT" ]; then \
echo "$(GOIMPORTS) FAILED => fix the import order in the following files:\n"; \
echo "$$IMPORTSOUT\n"; \
exit 1; \
else \
echo "Goimports finished successfully"; \
fi

.PHONY: vet
vet:
@$(GOVET) ./...
@echo "Vet finished successfully"

.PHONY: install-tools
install-tools:
GO111MODULE=on go install github.com/google/addlicense
GO111MODULE=on go install golang.org/x/lint/golint
GO111MODULE=on go install \
github.com/google/addlicense \
golang.org/x/lint/golint \
golang.org/x/tools/cmd/goimports

.PHONY: otelsvc
otelsvc:
Expand Down
1 change: 1 addition & 0 deletions internal/tools.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ import (
_ "github.com/google/addlicense"
_ "github.com/jstemmer/go-junit-report"
_ "golang.org/x/lint/golint"
_ "golang.org/x/tools/cmd/goimports"
)
1 change: 1 addition & 0 deletions receiver/prometheusreceiver/internal/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package internal

import (
"errors"

"github.com/prometheus/common/model"
"github.com/prometheus/prometheus/pkg/labels"
"github.com/prometheus/prometheus/scrape"
Expand Down
7 changes: 4 additions & 3 deletions receiver/prometheusreceiver/internal/metricsbuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,21 @@ package internal
import (
"errors"
"fmt"
"github.com/golang/protobuf/ptypes/wrappers"
"go.uber.org/zap"
"sort"
"strconv"
"strings"

commonpb "github.com/census-instrumentation/opencensus-proto/gen-go/agent/common/v1"
metricspb "github.com/census-instrumentation/opencensus-proto/gen-go/metrics/v1"
"github.com/golang/protobuf/ptypes/timestamp"
"github.com/open-telemetry/opentelemetry-service/consumer/consumerdata"
"github.com/golang/protobuf/ptypes/wrappers"
"github.com/prometheus/common/model"
"github.com/prometheus/prometheus/pkg/labels"
"github.com/prometheus/prometheus/pkg/textparse"
"github.com/prometheus/prometheus/scrape"
"go.uber.org/zap"

"github.com/open-telemetry/opentelemetry-service/consumer/consumerdata"
)

const metricsSuffixCount = "_count"
Expand Down
5 changes: 3 additions & 2 deletions receiver/prometheusreceiver/internal/metricsbuilder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,18 @@
package internal

import (
"github.com/golang/protobuf/ptypes/wrappers"
"reflect"
"testing"

commonpb "github.com/census-instrumentation/opencensus-proto/gen-go/agent/common/v1"
metricspb "github.com/census-instrumentation/opencensus-proto/gen-go/metrics/v1"
"github.com/open-telemetry/opentelemetry-service/exporter/exportertest"
"github.com/golang/protobuf/ptypes/wrappers"
"github.com/prometheus/common/model"
"github.com/prometheus/prometheus/pkg/labels"
"github.com/prometheus/prometheus/pkg/textparse"
"github.com/prometheus/prometheus/scrape"

"github.com/open-telemetry/opentelemetry-service/exporter/exportertest"
)

func Test_isUsefulLabel(t *testing.T) {
Expand Down
10 changes: 6 additions & 4 deletions receiver/prometheusreceiver/internal/ocastore.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,16 @@ package internal
import (
"context"
"errors"
"github.com/open-telemetry/opentelemetry-service/consumer"
"io"
"sync"
"sync/atomic"

"github.com/prometheus/prometheus/pkg/labels"
"github.com/prometheus/prometheus/scrape"
"github.com/prometheus/prometheus/storage"
"go.uber.org/zap"
"io"
"sync"
"sync/atomic"

"github.com/open-telemetry/opentelemetry-service/consumer"
)

const (
Expand Down
7 changes: 4 additions & 3 deletions receiver/prometheusreceiver/internal/ocastore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ package internal
import (
"context"
"fmt"
"github.com/go-kit/kit/log"
"github.com/open-telemetry/opentelemetry-service/consumer/consumerdata"
"github.com/prometheus/prometheus/discovery"
"net/http"
"net/http/httptest"
"net/url"
Expand All @@ -28,9 +25,13 @@ import (
"time"

metricspb "github.com/census-instrumentation/opencensus-proto/gen-go/metrics/v1"
"github.com/go-kit/kit/log"
"github.com/prometheus/prometheus/config"
sd_config "github.com/prometheus/prometheus/discovery/config"
"github.com/prometheus/prometheus/scrape"

"github.com/open-telemetry/opentelemetry-service/consumer/consumerdata"
"github.com/prometheus/prometheus/discovery"
)

func TestOcaStore(t *testing.T) {
Expand Down
8 changes: 5 additions & 3 deletions receiver/prometheusreceiver/internal/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,16 @@ package internal
import (
"context"
"errors"
"strings"
"sync/atomic"

commonpb "github.com/census-instrumentation/opencensus-proto/gen-go/agent/common/v1"
"github.com/open-telemetry/opentelemetry-service/consumer"
"github.com/prometheus/common/model"
"github.com/prometheus/prometheus/pkg/labels"
"github.com/prometheus/prometheus/storage"
"go.uber.org/zap"
"strings"
"sync/atomic"

"github.com/open-telemetry/opentelemetry-service/consumer"
)

const (
Expand Down
5 changes: 3 additions & 2 deletions receiver/prometheusreceiver/internal/transaction_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@ package internal

import (
"context"
"github.com/prometheus/prometheus/pkg/labels"
"github.com/prometheus/prometheus/scrape"
"reflect"
"testing"
"time"

"github.com/prometheus/prometheus/pkg/labels"
"github.com/prometheus/prometheus/scrape"
)

func Test_transaction(t *testing.T) {
Expand Down
1 change: 1 addition & 0 deletions service/builder/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package builder
import (
"flag"
"fmt"

"github.com/spf13/viper"
)

Expand Down

0 comments on commit 28bf4bd

Please sign in to comment.