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

Commit

Permalink
replace gofmt with goimports (#1197)
Browse files Browse the repository at this point in the history
* replace gofmt with goimports

- also fixed errors found by goimports.

* fix travis build.
  • Loading branch information
rghetia authored Feb 7, 2020
1 parent d835ff8 commit a7631f6
Show file tree
Hide file tree
Showing 16 changed files with 53 additions and 48 deletions.
27 changes: 14 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ ALL_PKGS := $(shell go list $(sort $(dir $(ALL_SRC))))
GOTEST_OPT?=-v -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
EMBEDMD=embedmd
Expand All @@ -17,14 +17,14 @@ TRACE_ID_LINT_EXCEPTION="type name will be used as trace.TraceID by other packag
TRACE_OPTION_LINT_EXCEPTION="type name will be used as trace.TraceOptions by other packages"
README_FILES := $(shell find . -name '*README.md' | sort | tr '\n' ' ')

.DEFAULT_GOAL := fmt-lint-vet-embedmd-test
.DEFAULT_GOAL := imports-lint-vet-embedmd-test

.PHONY: fmt-lint-vet-embedmd-test
fmt-lint-vet-embedmd-test: fmt lint vet embedmd test
.PHONY: imports-lint-vet-embedmd-test
imports-lint-vet-embedmd-test: imports lint vet embedmd test

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

all-pkgs:
@echo $(ALL_PKGS) | tr ' ' '\n' | sort
Expand All @@ -44,15 +44,15 @@ test-386:
test-with-coverage:
$(GOTEST) $(GOTEST_OPT_WITH_COVERAGE) $(ALL_PKGS)

.PHONY: fmt
fmt:
@FMTOUT=`$(GOFMT) -s -l $(ALL_SRC) 2>&1`; \
if [ "$$FMTOUT" ]; then \
echo "$(GOFMT) FAILED => gofmt the following files:\n"; \
echo "$$FMTOUT\n"; \
.PHONY: imports
imports:
@IMPORTSOUT=`$(GOIMPORTS) -l $(ALL_SRC) 2>&1`; \
if [ "$$IMPORTSOUT" ]; then \
echo "$(GOIMPORTS) FAILED => goimports the following files:\n"; \
echo "$$IMPORTSOUT\n"; \
exit 1; \
else \
echo "Fmt finished successfully"; \
echo "Imports finished successfully"; \
fi

.PHONY: lint
Expand Down Expand Up @@ -91,6 +91,7 @@ embedmd:

.PHONY: install-tools
install-tools:
go get -u golang.org/x/tools/cmd/cover
go get -u golang.org/x/lint/golint
go get -u golang.org/x/tools/cmd/cover
go get -u golang.org/x/tools/cmd/goimports
go get -u github.com/rakyll/embedmd
2 changes: 1 addition & 1 deletion examples/grpc/helloworld_client/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
package main

import (
"context"
"log"
"os"
"time"

"context"
"go.opencensus.io/examples/exporter"
pb "go.opencensus.io/examples/grpc/proto"
"go.opencensus.io/plugin/ocgrpc"
Expand Down
2 changes: 1 addition & 1 deletion examples/grpc/helloworld_server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
package main

import (
"context"
"log"
"math/rand"
"net"
"net/http"
"time"

"context"
"go.opencensus.io/examples/exporter"
pb "go.opencensus.io/examples/grpc/proto"
"go.opencensus.io/plugin/ocgrpc"
Expand Down
8 changes: 4 additions & 4 deletions examples/grpc/proto/helloworld.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions internal/testpb/test.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion plugin/ocgrpc/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ package ocgrpc

import (
"context"
"go.opencensus.io/trace"

"go.opencensus.io/trace"
"google.golang.org/grpc/stats"
)

Expand Down
7 changes: 3 additions & 4 deletions plugin/ocgrpc/grpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,16 @@
package ocgrpc

import (
"context"
"sync"
"testing"
"time"

"context"
"go.opencensus.io/stats/view"
"google.golang.org/grpc/metadata"
"google.golang.org/grpc/stats"

"go.opencensus.io/stats/view"
"go.opencensus.io/trace"

"google.golang.org/grpc/stats"
)

func TestClientHandler(t *testing.T) {
Expand Down
3 changes: 2 additions & 1 deletion plugin/ocgrpc/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ package ocgrpc

import (
"context"
"go.opencensus.io/trace"

"google.golang.org/grpc/stats"

"go.opencensus.io/trace"
)

// ServerHandler implements gRPC stats.Handler recording OpenCensus stats and
Expand Down
11 changes: 5 additions & 6 deletions plugin/ocgrpc/server_stats_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,18 @@
package ocgrpc

import (
"context"
"reflect"
"testing"

"context"
"go.opencensus.io/trace"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/stats"
"google.golang.org/grpc/status"

"go.opencensus.io/metric/metricdata"
"go.opencensus.io/stats/view"
"go.opencensus.io/tag"

"google.golang.org/grpc/codes"
"google.golang.org/grpc/stats"
"google.golang.org/grpc/status"
"go.opencensus.io/trace"
)

func TestServerDefaultCollections(t *testing.T) {
Expand Down
8 changes: 4 additions & 4 deletions plugin/ocgrpc/trace_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@
package ocgrpc

import (
"context"
"strings"

"google.golang.org/grpc/codes"

"context"
"go.opencensus.io/trace"
"go.opencensus.io/trace/propagation"
"google.golang.org/grpc/metadata"
"google.golang.org/grpc/stats"
"google.golang.org/grpc/status"

"go.opencensus.io/trace"
"go.opencensus.io/trace/propagation"
)

const traceContextKey = "grpc-trace-bin"
Expand Down
5 changes: 3 additions & 2 deletions plugin/ocgrpc/trace_common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@
package ocgrpc

import (
"context"
"testing"

"context"
"go.opencensus.io/trace"
"google.golang.org/grpc/metadata"
"google.golang.org/grpc/stats"

"go.opencensus.io/trace"
)

func TestClientHandler_traceTagRPC(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion plugin/ocgrpc/trace_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
package ocgrpc_test

import (
"context"
"io"
"testing"
"time"

"context"
"go.opencensus.io/internal/testpb"
"go.opencensus.io/trace"
)
Expand Down
5 changes: 3 additions & 2 deletions plugin/runmetrics/example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ package runmetrics_test
import (
"context"
"fmt"
"log"
"sort"

"go.opencensus.io/metric/metricdata"
"go.opencensus.io/metric/metricexport"
"go.opencensus.io/plugin/runmetrics"
"log"
"sort"
)

type printExporter struct {
Expand Down
5 changes: 3 additions & 2 deletions plugin/runmetrics/producer.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ package runmetrics

import (
"errors"
"runtime"
"sync"

"go.opencensus.io/metric"
"go.opencensus.io/metric/metricdata"
"go.opencensus.io/metric/metricproducer"
"runtime"
"sync"
)

type (
Expand Down
4 changes: 3 additions & 1 deletion plugin/runmetrics/producer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ package runmetrics_test

import (
"context"
"testing"

"github.com/stretchr/testify/assert"

"go.opencensus.io/metric/metricdata"
"go.opencensus.io/metric/metricexport"
"go.opencensus.io/metric/metricproducer"
"go.opencensus.io/plugin/runmetrics"
"testing"
)

type testExporter struct {
Expand Down
2 changes: 1 addition & 1 deletion trace/examples_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
package trace_test

import (
"context"
"fmt"

"context"
"go.opencensus.io/trace"
)

Expand Down

0 comments on commit a7631f6

Please sign in to comment.