Skip to content
This repository was archived by the owner on Jul 31, 2023. It is now read-only.

Commit a7631f6

Browse files
authored
replace gofmt with goimports (#1197)
* replace gofmt with goimports - also fixed errors found by goimports. * fix travis build.
1 parent d835ff8 commit a7631f6

File tree

16 files changed

+53
-48
lines changed

16 files changed

+53
-48
lines changed

Makefile

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ ALL_PKGS := $(shell go list $(sort $(dir $(ALL_SRC))))
88
GOTEST_OPT?=-v -race -timeout 30s
99
GOTEST_OPT_WITH_COVERAGE = $(GOTEST_OPT) -coverprofile=coverage.txt -covermode=atomic
1010
GOTEST=go test
11-
GOFMT=gofmt
11+
GOIMPORTS=goimports
1212
GOLINT=golint
1313
GOVET=go vet
1414
EMBEDMD=embedmd
@@ -17,14 +17,14 @@ TRACE_ID_LINT_EXCEPTION="type name will be used as trace.TraceID by other packag
1717
TRACE_OPTION_LINT_EXCEPTION="type name will be used as trace.TraceOptions by other packages"
1818
README_FILES := $(shell find . -name '*README.md' | sort | tr '\n' ' ')
1919

20-
.DEFAULT_GOAL := fmt-lint-vet-embedmd-test
20+
.DEFAULT_GOAL := imports-lint-vet-embedmd-test
2121

22-
.PHONY: fmt-lint-vet-embedmd-test
23-
fmt-lint-vet-embedmd-test: fmt lint vet embedmd test
22+
.PHONY: imports-lint-vet-embedmd-test
23+
imports-lint-vet-embedmd-test: imports lint vet embedmd test
2424

2525
# TODO enable test-with-coverage in tavis
2626
.PHONY: travis-ci
27-
travis-ci: fmt lint vet embedmd test test-386
27+
travis-ci: imports lint vet embedmd test test-386
2828

2929
all-pkgs:
3030
@echo $(ALL_PKGS) | tr ' ' '\n' | sort
@@ -44,15 +44,15 @@ test-386:
4444
test-with-coverage:
4545
$(GOTEST) $(GOTEST_OPT_WITH_COVERAGE) $(ALL_PKGS)
4646

47-
.PHONY: fmt
48-
fmt:
49-
@FMTOUT=`$(GOFMT) -s -l $(ALL_SRC) 2>&1`; \
50-
if [ "$$FMTOUT" ]; then \
51-
echo "$(GOFMT) FAILED => gofmt the following files:\n"; \
52-
echo "$$FMTOUT\n"; \
47+
.PHONY: imports
48+
imports:
49+
@IMPORTSOUT=`$(GOIMPORTS) -l $(ALL_SRC) 2>&1`; \
50+
if [ "$$IMPORTSOUT" ]; then \
51+
echo "$(GOIMPORTS) FAILED => goimports the following files:\n"; \
52+
echo "$$IMPORTSOUT\n"; \
5353
exit 1; \
5454
else \
55-
echo "Fmt finished successfully"; \
55+
echo "Imports finished successfully"; \
5656
fi
5757

5858
.PHONY: lint
@@ -91,6 +91,7 @@ embedmd:
9191

9292
.PHONY: install-tools
9393
install-tools:
94-
go get -u golang.org/x/tools/cmd/cover
9594
go get -u golang.org/x/lint/golint
95+
go get -u golang.org/x/tools/cmd/cover
96+
go get -u golang.org/x/tools/cmd/goimports
9697
go get -u github.com/rakyll/embedmd

examples/grpc/helloworld_client/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@
1515
package main
1616

1717
import (
18+
"context"
1819
"log"
1920
"os"
2021
"time"
2122

22-
"context"
2323
"go.opencensus.io/examples/exporter"
2424
pb "go.opencensus.io/examples/grpc/proto"
2525
"go.opencensus.io/plugin/ocgrpc"

examples/grpc/helloworld_server/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@
1717
package main
1818

1919
import (
20+
"context"
2021
"log"
2122
"math/rand"
2223
"net"
2324
"net/http"
2425
"time"
2526

26-
"context"
2727
"go.opencensus.io/examples/exporter"
2828
pb "go.opencensus.io/examples/grpc/proto"
2929
"go.opencensus.io/plugin/ocgrpc"

examples/grpc/proto/helloworld.pb.go

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/testpb/test.pb.go

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

plugin/ocgrpc/client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ package ocgrpc
1616

1717
import (
1818
"context"
19-
"go.opencensus.io/trace"
2019

20+
"go.opencensus.io/trace"
2121
"google.golang.org/grpc/stats"
2222
)
2323

plugin/ocgrpc/grpc_test.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,16 @@
1515
package ocgrpc
1616

1717
import (
18+
"context"
1819
"sync"
1920
"testing"
2021
"time"
2122

22-
"context"
23-
"go.opencensus.io/stats/view"
2423
"google.golang.org/grpc/metadata"
24+
"google.golang.org/grpc/stats"
2525

26+
"go.opencensus.io/stats/view"
2627
"go.opencensus.io/trace"
27-
28-
"google.golang.org/grpc/stats"
2928
)
3029

3130
func TestClientHandler(t *testing.T) {

plugin/ocgrpc/server.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@ package ocgrpc
1616

1717
import (
1818
"context"
19-
"go.opencensus.io/trace"
2019

2120
"google.golang.org/grpc/stats"
21+
22+
"go.opencensus.io/trace"
2223
)
2324

2425
// ServerHandler implements gRPC stats.Handler recording OpenCensus stats and

plugin/ocgrpc/server_stats_handler_test.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,18 @@
1616
package ocgrpc
1717

1818
import (
19+
"context"
1920
"reflect"
2021
"testing"
2122

22-
"context"
23-
"go.opencensus.io/trace"
23+
"google.golang.org/grpc/codes"
24+
"google.golang.org/grpc/stats"
25+
"google.golang.org/grpc/status"
2426

2527
"go.opencensus.io/metric/metricdata"
2628
"go.opencensus.io/stats/view"
2729
"go.opencensus.io/tag"
28-
29-
"google.golang.org/grpc/codes"
30-
"google.golang.org/grpc/stats"
31-
"google.golang.org/grpc/status"
30+
"go.opencensus.io/trace"
3231
)
3332

3433
func TestServerDefaultCollections(t *testing.T) {

plugin/ocgrpc/trace_common.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,16 @@
1515
package ocgrpc
1616

1717
import (
18+
"context"
1819
"strings"
1920

2021
"google.golang.org/grpc/codes"
21-
22-
"context"
23-
"go.opencensus.io/trace"
24-
"go.opencensus.io/trace/propagation"
2522
"google.golang.org/grpc/metadata"
2623
"google.golang.org/grpc/stats"
2724
"google.golang.org/grpc/status"
25+
26+
"go.opencensus.io/trace"
27+
"go.opencensus.io/trace/propagation"
2828
)
2929

3030
const traceContextKey = "grpc-trace-bin"

0 commit comments

Comments
 (0)