From 4d950507475c9f7b452de5ef865aa96ffb65d773 Mon Sep 17 00:00:00 2001 From: "jesse.tang" <1430482733@qq.com> Date: Tue, 27 Sep 2022 14:08:08 +0800 Subject: [PATCH] fix: fmt import (#2379) --- api/metadata/server.go | 3 ++- cmd/kratos/internal/project/add.go | 1 + cmd/kratos/internal/project/project.go | 3 ++- cmd/protoc-gen-go-errors/errors.go | 3 ++- config/file/watcher.go | 1 + contrib/config/apollo/apollo.go | 1 + contrib/config/consul/config.go | 3 ++- contrib/config/consul/config_test.go | 3 ++- contrib/config/consul/watcher.go | 3 ++- contrib/config/etcd/config.go | 3 ++- contrib/config/etcd/watcher.go | 3 ++- contrib/config/kubernetes/config.go | 3 ++- contrib/config/kubernetes/watcher.go | 3 ++- contrib/config/nacos/watcher.go | 3 ++- contrib/log/aliyun/aliyun.go | 3 ++- contrib/log/fluent/fluent.go | 1 + contrib/log/logrus/logrus.go | 3 ++- contrib/log/logrus/logrus_test.go | 3 ++- contrib/log/tencent/tencent.go | 3 ++- contrib/log/zap/zap.go | 3 ++- contrib/metrics/prometheus/counter.go | 3 ++- contrib/metrics/prometheus/gauge.go | 3 ++- contrib/metrics/prometheus/histogram.go | 3 ++- contrib/metrics/prometheus/summary.go | 3 ++- contrib/registry/consul/registry_test.go | 3 ++- contrib/registry/discovery/discovery.go | 3 ++- contrib/registry/etcd/registry.go | 3 ++- contrib/registry/etcd/registry_test.go | 3 ++- contrib/registry/etcd/watcher.go | 3 ++- contrib/registry/kubernetes/registry.go | 3 ++- contrib/registry/nacos/watcher.go | 3 ++- contrib/registry/zookeeper/register_test.go | 3 ++- contrib/registry/zookeeper/watcher.go | 3 ++- encoding/json/json.go | 3 ++- encoding/yaml/yaml.go | 3 ++- errors/errors.go | 3 ++- middleware/circuitbreaker/circuitbreaker.go | 1 + middleware/ratelimit/ratelimit.go | 1 + middleware/tracing/metadata.go | 3 ++- middleware/tracing/span_test.go | 7 ++++--- middleware/tracing/tracer.go | 3 ++- middleware/tracing/tracer_test.go | 3 ++- middleware/tracing/tracing.go | 5 +++-- middleware/tracing/tracing_test.go | 5 +++-- transport/grpc/balancer_test.go | 3 ++- transport/grpc/client_test.go | 3 ++- transport/grpc/codec.go | 5 +++-- transport/grpc/interceptor.go | 5 +++-- transport/grpc/resolver/discovery/builder_test.go | 3 ++- transport/grpc/resolver/discovery/resolver_test.go | 3 ++- transport/grpc/server_test.go | 3 ++- transport/grpc/transport.go | 3 ++- transport/http/binding/encode_test.go | 3 ++- transport/http/context.go | 3 ++- 54 files changed, 108 insertions(+), 54 deletions(-) diff --git a/api/metadata/server.go b/api/metadata/server.go index 96f0e1e67..39e468ec5 100644 --- a/api/metadata/server.go +++ b/api/metadata/server.go @@ -9,7 +9,6 @@ import ( "io" "sync" - "github.com/go-kratos/kratos/v2/log" "google.golang.org/grpc" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" @@ -18,6 +17,8 @@ import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" "google.golang.org/protobuf/reflect/protoregistry" dpb "google.golang.org/protobuf/types/descriptorpb" + + "github.com/go-kratos/kratos/v2/log" ) // Server is api meta server diff --git a/cmd/kratos/internal/project/add.go b/cmd/kratos/internal/project/add.go index f4c1b88c3..9f30bfcb9 100644 --- a/cmd/kratos/internal/project/add.go +++ b/cmd/kratos/internal/project/add.go @@ -8,6 +8,7 @@ import ( "github.com/AlecAivazis/survey/v2" "github.com/fatih/color" + "github.com/go-kratos/kratos/cmd/kratos/v2/internal/base" ) diff --git a/cmd/kratos/internal/project/project.go b/cmd/kratos/internal/project/project.go index 8ea7f2a99..271ad3731 100644 --- a/cmd/kratos/internal/project/project.go +++ b/cmd/kratos/internal/project/project.go @@ -9,8 +9,9 @@ import ( "time" "github.com/AlecAivazis/survey/v2" - "github.com/go-kratos/kratos/cmd/kratos/v2/internal/base" "github.com/spf13/cobra" + + "github.com/go-kratos/kratos/cmd/kratos/v2/internal/base" ) // CmdNew represents the new command. diff --git a/cmd/protoc-gen-go-errors/errors.go b/cmd/protoc-gen-go-errors/errors.go index 6a0973303..522c29685 100644 --- a/cmd/protoc-gen-go-errors/errors.go +++ b/cmd/protoc-gen-go-errors/errors.go @@ -8,9 +8,10 @@ import ( "golang.org/x/text/cases" "golang.org/x/text/language" - "github.com/go-kratos/kratos/cmd/protoc-gen-go-errors/v2/errors" "google.golang.org/protobuf/compiler/protogen" "google.golang.org/protobuf/proto" + + "github.com/go-kratos/kratos/cmd/protoc-gen-go-errors/v2/errors" ) const ( diff --git a/config/file/watcher.go b/config/file/watcher.go index 4c00b0462..ea309fa87 100644 --- a/config/file/watcher.go +++ b/config/file/watcher.go @@ -6,6 +6,7 @@ import ( "path/filepath" "github.com/fsnotify/fsnotify" + "github.com/go-kratos/kratos/v2/config" ) diff --git a/contrib/config/apollo/apollo.go b/contrib/config/apollo/apollo.go index 5f868bab9..259ed1a90 100644 --- a/contrib/config/apollo/apollo.go +++ b/contrib/config/apollo/apollo.go @@ -10,6 +10,7 @@ import ( "github.com/apolloconfig/agollo/v4/constant" apolloConfig "github.com/apolloconfig/agollo/v4/env/config" "github.com/apolloconfig/agollo/v4/extension" + "github.com/go-kratos/kratos/v2/encoding" ) diff --git a/contrib/config/consul/config.go b/contrib/config/consul/config.go index f42611e0b..dca8a88e7 100644 --- a/contrib/config/consul/config.go +++ b/contrib/config/consul/config.go @@ -6,8 +6,9 @@ import ( "path/filepath" "strings" - "github.com/go-kratos/kratos/v2/config" "github.com/hashicorp/consul/api" + + "github.com/go-kratos/kratos/v2/config" ) // Option is etcd config option. diff --git a/contrib/config/consul/config_test.go b/contrib/config/consul/config_test.go index a82a20369..adb3c27c0 100644 --- a/contrib/config/consul/config_test.go +++ b/contrib/config/consul/config_test.go @@ -5,8 +5,9 @@ import ( "testing" "time" - "github.com/go-kratos/kratos/v2/config" "github.com/hashicorp/consul/api" + + "github.com/go-kratos/kratos/v2/config" ) const testPath = "kratos/test/config" diff --git a/contrib/config/consul/watcher.go b/contrib/config/consul/watcher.go index baee9ef67..5c70d6f85 100644 --- a/contrib/config/consul/watcher.go +++ b/contrib/config/consul/watcher.go @@ -3,9 +3,10 @@ package consul import ( "context" - "github.com/go-kratos/kratos/v2/config" "github.com/hashicorp/consul/api" "github.com/hashicorp/consul/api/watch" + + "github.com/go-kratos/kratos/v2/config" ) type watcher struct { diff --git a/contrib/config/etcd/config.go b/contrib/config/etcd/config.go index 37059e10e..76045a58c 100644 --- a/contrib/config/etcd/config.go +++ b/contrib/config/etcd/config.go @@ -6,8 +6,9 @@ import ( "path/filepath" "strings" - "github.com/go-kratos/kratos/v2/config" clientv3 "go.etcd.io/etcd/client/v3" + + "github.com/go-kratos/kratos/v2/config" ) // Option is etcd config option. diff --git a/contrib/config/etcd/watcher.go b/contrib/config/etcd/watcher.go index 388c2dd86..dd2ea9112 100644 --- a/contrib/config/etcd/watcher.go +++ b/contrib/config/etcd/watcher.go @@ -3,8 +3,9 @@ package etcd import ( "context" - "github.com/go-kratos/kratos/v2/config" clientv3 "go.etcd.io/etcd/client/v3" + + "github.com/go-kratos/kratos/v2/config" ) type watcher struct { diff --git a/contrib/config/kubernetes/config.go b/contrib/config/kubernetes/config.go index c66b837f5..12026fe86 100644 --- a/contrib/config/kubernetes/config.go +++ b/contrib/config/kubernetes/config.go @@ -7,12 +7,13 @@ import ( "path/filepath" "strings" - "github.com/go-kratos/kratos/v2/config" v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/client-go/kubernetes" "k8s.io/client-go/rest" "k8s.io/client-go/tools/clientcmd" + + "github.com/go-kratos/kratos/v2/config" ) // Option is kubernetes option. diff --git a/contrib/config/kubernetes/watcher.go b/contrib/config/kubernetes/watcher.go index 87872b8d7..c13a8a7ef 100644 --- a/contrib/config/kubernetes/watcher.go +++ b/contrib/config/kubernetes/watcher.go @@ -4,10 +4,11 @@ import ( "context" "fmt" - "github.com/go-kratos/kratos/v2/config" v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/watch" + + "github.com/go-kratos/kratos/v2/config" ) type watcher struct { diff --git a/contrib/config/nacos/watcher.go b/contrib/config/nacos/watcher.go index e190b6889..fd528af7a 100644 --- a/contrib/config/nacos/watcher.go +++ b/contrib/config/nacos/watcher.go @@ -5,8 +5,9 @@ import ( "path/filepath" "strings" - "github.com/go-kratos/kratos/v2/config" "github.com/nacos-group/nacos-sdk-go/vo" + + "github.com/go-kratos/kratos/v2/config" ) type Watcher struct { diff --git a/contrib/log/aliyun/aliyun.go b/contrib/log/aliyun/aliyun.go index a20d9ab69..390cb571e 100644 --- a/contrib/log/aliyun/aliyun.go +++ b/contrib/log/aliyun/aliyun.go @@ -7,8 +7,9 @@ import ( sls "github.com/aliyun/aliyun-log-go-sdk" "github.com/aliyun/aliyun-log-go-sdk/producer" - log "github.com/go-kratos/kratos/v2/log" "google.golang.org/protobuf/proto" + + log "github.com/go-kratos/kratos/v2/log" ) // Logger see more detail https://github.com/aliyun/aliyun-log-go-sdk diff --git a/contrib/log/fluent/fluent.go b/contrib/log/fluent/fluent.go index 07a15b869..86e86993e 100644 --- a/contrib/log/fluent/fluent.go +++ b/contrib/log/fluent/fluent.go @@ -8,6 +8,7 @@ import ( "time" "github.com/fluent/fluent-logger-golang/fluent" + "github.com/go-kratos/kratos/v2/log" ) diff --git a/contrib/log/logrus/logrus.go b/contrib/log/logrus/logrus.go index b08ba6e13..6fda38c50 100644 --- a/contrib/log/logrus/logrus.go +++ b/contrib/log/logrus/logrus.go @@ -1,8 +1,9 @@ package logrus import ( - "github.com/go-kratos/kratos/v2/log" "github.com/sirupsen/logrus" + + "github.com/go-kratos/kratos/v2/log" ) var _ log.Logger = (*Logger)(nil) diff --git a/contrib/log/logrus/logrus_test.go b/contrib/log/logrus/logrus_test.go index 50b7a99b4..45fe9da2d 100644 --- a/contrib/log/logrus/logrus_test.go +++ b/contrib/log/logrus/logrus_test.go @@ -5,8 +5,9 @@ import ( "strings" "testing" - "github.com/go-kratos/kratos/v2/log" "github.com/sirupsen/logrus" + + "github.com/go-kratos/kratos/v2/log" ) func TestLoggerLog(t *testing.T) { diff --git a/contrib/log/tencent/tencent.go b/contrib/log/tencent/tencent.go index 5d7267f26..40cc98cdb 100644 --- a/contrib/log/tencent/tencent.go +++ b/contrib/log/tencent/tencent.go @@ -6,9 +6,10 @@ import ( "strconv" "time" - log "github.com/go-kratos/kratos/v2/log" cls "github.com/tencentcloud/tencentcloud-cls-sdk-go" "google.golang.org/protobuf/proto" + + log "github.com/go-kratos/kratos/v2/log" ) type Logger interface { diff --git a/contrib/log/zap/zap.go b/contrib/log/zap/zap.go index 5929c4860..511381f9d 100644 --- a/contrib/log/zap/zap.go +++ b/contrib/log/zap/zap.go @@ -3,8 +3,9 @@ package zap import ( "fmt" - "github.com/go-kratos/kratos/v2/log" "go.uber.org/zap" + + "github.com/go-kratos/kratos/v2/log" ) var _ log.Logger = (*Logger)(nil) diff --git a/contrib/metrics/prometheus/counter.go b/contrib/metrics/prometheus/counter.go index 8b90beabd..5873c017a 100644 --- a/contrib/metrics/prometheus/counter.go +++ b/contrib/metrics/prometheus/counter.go @@ -1,8 +1,9 @@ package prometheus import ( - "github.com/go-kratos/kratos/v2/metrics" "github.com/prometheus/client_golang/prometheus" + + "github.com/go-kratos/kratos/v2/metrics" ) var _ metrics.Counter = (*counter)(nil) diff --git a/contrib/metrics/prometheus/gauge.go b/contrib/metrics/prometheus/gauge.go index 6df11d691..25750b6ca 100644 --- a/contrib/metrics/prometheus/gauge.go +++ b/contrib/metrics/prometheus/gauge.go @@ -1,8 +1,9 @@ package prometheus import ( - "github.com/go-kratos/kratos/v2/metrics" "github.com/prometheus/client_golang/prometheus" + + "github.com/go-kratos/kratos/v2/metrics" ) var _ metrics.Gauge = (*gauge)(nil) diff --git a/contrib/metrics/prometheus/histogram.go b/contrib/metrics/prometheus/histogram.go index 81b3b2812..a0245d73c 100644 --- a/contrib/metrics/prometheus/histogram.go +++ b/contrib/metrics/prometheus/histogram.go @@ -1,8 +1,9 @@ package prometheus import ( - "github.com/go-kratos/kratos/v2/metrics" "github.com/prometheus/client_golang/prometheus" + + "github.com/go-kratos/kratos/v2/metrics" ) var _ metrics.Observer = (*histogram)(nil) diff --git a/contrib/metrics/prometheus/summary.go b/contrib/metrics/prometheus/summary.go index d8bcad91d..25969edfa 100644 --- a/contrib/metrics/prometheus/summary.go +++ b/contrib/metrics/prometheus/summary.go @@ -1,8 +1,9 @@ package prometheus import ( - "github.com/go-kratos/kratos/v2/metrics" "github.com/prometheus/client_golang/prometheus" + + "github.com/go-kratos/kratos/v2/metrics" ) var _ metrics.Observer = (*summary)(nil) diff --git a/contrib/registry/consul/registry_test.go b/contrib/registry/consul/registry_test.go index 483faf1ad..6a1523c48 100644 --- a/contrib/registry/consul/registry_test.go +++ b/contrib/registry/consul/registry_test.go @@ -8,8 +8,9 @@ import ( "testing" "time" - "github.com/go-kratos/kratos/v2/registry" "github.com/hashicorp/consul/api" + + "github.com/go-kratos/kratos/v2/registry" ) func tcpServer(t *testing.T, lis net.Listener) { diff --git a/contrib/registry/discovery/discovery.go b/contrib/registry/discovery/discovery.go index 32f3f67cd..f439b0cab 100644 --- a/contrib/registry/discovery/discovery.go +++ b/contrib/registry/discovery/discovery.go @@ -10,9 +10,10 @@ import ( "sync/atomic" "time" - "github.com/go-kratos/kratos/v2/log" "github.com/go-resty/resty/v2" "github.com/pkg/errors" + + "github.com/go-kratos/kratos/v2/log" ) type Discovery struct { diff --git a/contrib/registry/etcd/registry.go b/contrib/registry/etcd/registry.go index 76c114a0b..5592f62d2 100644 --- a/contrib/registry/etcd/registry.go +++ b/contrib/registry/etcd/registry.go @@ -6,8 +6,9 @@ import ( "math/rand" "time" - "github.com/go-kratos/kratos/v2/registry" clientv3 "go.etcd.io/etcd/client/v3" + + "github.com/go-kratos/kratos/v2/registry" ) var ( diff --git a/contrib/registry/etcd/registry_test.go b/contrib/registry/etcd/registry_test.go index 844d67ffc..8fcecf945 100644 --- a/contrib/registry/etcd/registry_test.go +++ b/contrib/registry/etcd/registry_test.go @@ -8,8 +8,9 @@ import ( "google.golang.org/grpc" - "github.com/go-kratos/kratos/v2/registry" clientv3 "go.etcd.io/etcd/client/v3" + + "github.com/go-kratos/kratos/v2/registry" ) func TestRegistry(t *testing.T) { diff --git a/contrib/registry/etcd/watcher.go b/contrib/registry/etcd/watcher.go index a5bf63c41..0e531a99b 100644 --- a/contrib/registry/etcd/watcher.go +++ b/contrib/registry/etcd/watcher.go @@ -3,8 +3,9 @@ package etcd import ( "context" - "github.com/go-kratos/kratos/v2/registry" clientv3 "go.etcd.io/etcd/client/v3" + + "github.com/go-kratos/kratos/v2/registry" ) var _ registry.Watcher = (*watcher)(nil) diff --git a/contrib/registry/kubernetes/registry.go b/contrib/registry/kubernetes/registry.go index 253903629..987ef1e1e 100644 --- a/contrib/registry/kubernetes/registry.go +++ b/contrib/registry/kubernetes/registry.go @@ -11,7 +11,6 @@ import ( "strings" "time" - "github.com/go-kratos/kratos/v2/registry" jsoniter "github.com/json-iterator/go" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -21,6 +20,8 @@ import ( "k8s.io/client-go/kubernetes" listerv1 "k8s.io/client-go/listers/core/v1" "k8s.io/client-go/tools/cache" + + "github.com/go-kratos/kratos/v2/registry" ) // Defines the key name of specific fields diff --git a/contrib/registry/nacos/watcher.go b/contrib/registry/nacos/watcher.go index c5d652fc6..78b4fc21b 100644 --- a/contrib/registry/nacos/watcher.go +++ b/contrib/registry/nacos/watcher.go @@ -4,10 +4,11 @@ import ( "context" "fmt" - "github.com/go-kratos/kratos/v2/registry" "github.com/nacos-group/nacos-sdk-go/clients/naming_client" "github.com/nacos-group/nacos-sdk-go/model" "github.com/nacos-group/nacos-sdk-go/vo" + + "github.com/go-kratos/kratos/v2/registry" ) var _ registry.Watcher = (*watcher)(nil) diff --git a/contrib/registry/zookeeper/register_test.go b/contrib/registry/zookeeper/register_test.go index 131f3ee12..a6f4515e5 100644 --- a/contrib/registry/zookeeper/register_test.go +++ b/contrib/registry/zookeeper/register_test.go @@ -6,8 +6,9 @@ import ( "testing" "time" - "github.com/go-kratos/kratos/v2/registry" "github.com/go-zookeeper/zk" + + "github.com/go-kratos/kratos/v2/registry" ) func TestRegistry_GetService(t *testing.T) { diff --git a/contrib/registry/zookeeper/watcher.go b/contrib/registry/zookeeper/watcher.go index f20096754..ddb98a84c 100644 --- a/contrib/registry/zookeeper/watcher.go +++ b/contrib/registry/zookeeper/watcher.go @@ -6,8 +6,9 @@ import ( "path" "sync/atomic" - "github.com/go-kratos/kratos/v2/registry" "github.com/go-zookeeper/zk" + + "github.com/go-kratos/kratos/v2/registry" ) var _ registry.Watcher = (*watcher)(nil) diff --git a/encoding/json/json.go b/encoding/json/json.go index d5e020b76..c1982190e 100644 --- a/encoding/json/json.go +++ b/encoding/json/json.go @@ -4,9 +4,10 @@ import ( "encoding/json" "reflect" - "github.com/go-kratos/kratos/v2/encoding" "google.golang.org/protobuf/encoding/protojson" "google.golang.org/protobuf/proto" + + "github.com/go-kratos/kratos/v2/encoding" ) // Name is the name registered for the json codec. diff --git a/encoding/yaml/yaml.go b/encoding/yaml/yaml.go index b2f885f0c..1364b24c1 100644 --- a/encoding/yaml/yaml.go +++ b/encoding/yaml/yaml.go @@ -1,8 +1,9 @@ package yaml import ( - "github.com/go-kratos/kratos/v2/encoding" "gopkg.in/yaml.v3" + + "github.com/go-kratos/kratos/v2/encoding" ) // Name is the name registered for the yaml codec. diff --git a/errors/errors.go b/errors/errors.go index fd95ff3b7..caf31cd3e 100644 --- a/errors/errors.go +++ b/errors/errors.go @@ -4,9 +4,10 @@ import ( "errors" "fmt" - httpstatus "github.com/go-kratos/kratos/v2/transport/http/status" "google.golang.org/genproto/googleapis/rpc/errdetails" "google.golang.org/grpc/status" + + httpstatus "github.com/go-kratos/kratos/v2/transport/http/status" ) const ( diff --git a/middleware/circuitbreaker/circuitbreaker.go b/middleware/circuitbreaker/circuitbreaker.go index c7ab178e5..31433ee71 100644 --- a/middleware/circuitbreaker/circuitbreaker.go +++ b/middleware/circuitbreaker/circuitbreaker.go @@ -5,6 +5,7 @@ import ( "github.com/go-kratos/aegis/circuitbreaker" "github.com/go-kratos/aegis/circuitbreaker/sre" + "github.com/go-kratos/kratos/v2/errors" "github.com/go-kratos/kratos/v2/internal/group" "github.com/go-kratos/kratos/v2/middleware" diff --git a/middleware/ratelimit/ratelimit.go b/middleware/ratelimit/ratelimit.go index 5bfae27b1..23f217530 100644 --- a/middleware/ratelimit/ratelimit.go +++ b/middleware/ratelimit/ratelimit.go @@ -5,6 +5,7 @@ import ( "github.com/go-kratos/aegis/ratelimit" "github.com/go-kratos/aegis/ratelimit/bbr" + "github.com/go-kratos/kratos/v2/errors" "github.com/go-kratos/kratos/v2/middleware" ) diff --git a/middleware/tracing/metadata.go b/middleware/tracing/metadata.go index 01e511329..7ad82806a 100644 --- a/middleware/tracing/metadata.go +++ b/middleware/tracing/metadata.go @@ -3,9 +3,10 @@ package tracing import ( "context" + "go.opentelemetry.io/otel/propagation" + "github.com/go-kratos/kratos/v2" "github.com/go-kratos/kratos/v2/metadata" - "go.opentelemetry.io/otel/propagation" ) const serviceHeader = "x-md-service-name" diff --git a/middleware/tracing/span_test.go b/middleware/tracing/span_test.go index aad4614fc..110dc6f5e 100644 --- a/middleware/tracing/span_test.go +++ b/middleware/tracing/span_test.go @@ -7,13 +7,14 @@ import ( "reflect" "testing" - "github.com/go-kratos/kratos/v2/internal/testdata/binding" - "github.com/go-kratos/kratos/v2/metadata" - "github.com/go-kratos/kratos/v2/transport" "go.opentelemetry.io/otel/attribute" semconv "go.opentelemetry.io/otel/semconv/v1.4.0" "go.opentelemetry.io/otel/trace" "google.golang.org/grpc/peer" + + "github.com/go-kratos/kratos/v2/internal/testdata/binding" + "github.com/go-kratos/kratos/v2/metadata" + "github.com/go-kratos/kratos/v2/transport" ) func Test_parseFullMethod(t *testing.T) { diff --git a/middleware/tracing/tracer.go b/middleware/tracing/tracer.go index cf9115bbf..798994f87 100644 --- a/middleware/tracing/tracer.go +++ b/middleware/tracing/tracer.go @@ -4,13 +4,14 @@ import ( "context" "fmt" - "github.com/go-kratos/kratos/v2/errors" "go.opentelemetry.io/otel" "go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/codes" "go.opentelemetry.io/otel/propagation" "go.opentelemetry.io/otel/trace" "google.golang.org/protobuf/proto" + + "github.com/go-kratos/kratos/v2/errors" ) // Tracer is otel span tracer diff --git a/middleware/tracing/tracer_test.go b/middleware/tracing/tracer_test.go index fbd51c070..af63844e2 100644 --- a/middleware/tracing/tracer_test.go +++ b/middleware/tracing/tracer_test.go @@ -5,8 +5,9 @@ import ( "errors" "testing" - "github.com/go-kratos/kratos/v2/internal/testdata/binding" "go.opentelemetry.io/otel/trace" + + "github.com/go-kratos/kratos/v2/internal/testdata/binding" ) func Test_NewTracer(t *testing.T) { diff --git a/middleware/tracing/tracing.go b/middleware/tracing/tracing.go index 167725f40..b89ce0a22 100644 --- a/middleware/tracing/tracing.go +++ b/middleware/tracing/tracing.go @@ -5,10 +5,11 @@ import ( "github.com/go-kratos/kratos/v2/log" - "github.com/go-kratos/kratos/v2/middleware" - "github.com/go-kratos/kratos/v2/transport" "go.opentelemetry.io/otel/propagation" "go.opentelemetry.io/otel/trace" + + "github.com/go-kratos/kratos/v2/middleware" + "github.com/go-kratos/kratos/v2/transport" ) // Option is tracing option. diff --git a/middleware/tracing/tracing_test.go b/middleware/tracing/tracing_test.go index 222a6accd..b95771ab9 100644 --- a/middleware/tracing/tracing_test.go +++ b/middleware/tracing/tracing_test.go @@ -7,11 +7,12 @@ import ( "reflect" "testing" - "github.com/go-kratos/kratos/v2/log" - "github.com/go-kratos/kratos/v2/transport" "go.opentelemetry.io/otel/propagation" tracesdk "go.opentelemetry.io/otel/sdk/trace" "go.opentelemetry.io/otel/trace" + + "github.com/go-kratos/kratos/v2/log" + "github.com/go-kratos/kratos/v2/transport" ) var _ transport.Transporter = (*mockTransport)(nil) diff --git a/transport/grpc/balancer_test.go b/transport/grpc/balancer_test.go index 5b7002643..2dbb53bb9 100644 --- a/transport/grpc/balancer_test.go +++ b/transport/grpc/balancer_test.go @@ -5,8 +5,9 @@ import ( "reflect" "testing" - "github.com/go-kratos/kratos/v2/selector" "google.golang.org/grpc/metadata" + + "github.com/go-kratos/kratos/v2/selector" ) func TestTrailer(t *testing.T) { diff --git a/transport/grpc/client_test.go b/transport/grpc/client_test.go index d2540a7db..7ad553686 100644 --- a/transport/grpc/client_test.go +++ b/transport/grpc/client_test.go @@ -7,9 +7,10 @@ import ( "testing" "time" + "google.golang.org/grpc" + "github.com/go-kratos/kratos/v2/middleware" "github.com/go-kratos/kratos/v2/registry" - "google.golang.org/grpc" ) func TestWithEndpoint(t *testing.T) { diff --git a/transport/grpc/codec.go b/transport/grpc/codec.go index 19670bbab..231f114f8 100644 --- a/transport/grpc/codec.go +++ b/transport/grpc/codec.go @@ -3,10 +3,11 @@ package grpc import ( "fmt" - enc "github.com/go-kratos/kratos/v2/encoding" - "github.com/go-kratos/kratos/v2/encoding/json" "google.golang.org/grpc/encoding" "google.golang.org/protobuf/proto" + + enc "github.com/go-kratos/kratos/v2/encoding" + "github.com/go-kratos/kratos/v2/encoding/json" ) func init() { diff --git a/transport/grpc/interceptor.go b/transport/grpc/interceptor.go index ccd83ea69..6cc331547 100644 --- a/transport/grpc/interceptor.go +++ b/transport/grpc/interceptor.go @@ -3,11 +3,12 @@ package grpc import ( "context" + "google.golang.org/grpc" + grpcmd "google.golang.org/grpc/metadata" + ic "github.com/go-kratos/kratos/v2/internal/context" "github.com/go-kratos/kratos/v2/middleware" "github.com/go-kratos/kratos/v2/transport" - "google.golang.org/grpc" - grpcmd "google.golang.org/grpc/metadata" ) // unaryServerInterceptor is a gRPC unary server interceptor diff --git a/transport/grpc/resolver/discovery/builder_test.go b/transport/grpc/resolver/discovery/builder_test.go index 770f12f1a..664b5d44d 100644 --- a/transport/grpc/resolver/discovery/builder_test.go +++ b/transport/grpc/resolver/discovery/builder_test.go @@ -7,9 +7,10 @@ import ( "testing" "time" - "github.com/go-kratos/kratos/v2/registry" "google.golang.org/grpc/resolver" "google.golang.org/grpc/serviceconfig" + + "github.com/go-kratos/kratos/v2/registry" ) func TestWithInsecure(t *testing.T) { diff --git a/transport/grpc/resolver/discovery/resolver_test.go b/transport/grpc/resolver/discovery/resolver_test.go index 33d9fc27e..39ae400e9 100644 --- a/transport/grpc/resolver/discovery/resolver_test.go +++ b/transport/grpc/resolver/discovery/resolver_test.go @@ -7,8 +7,9 @@ import ( "testing" "time" - "github.com/go-kratos/kratos/v2/registry" "google.golang.org/grpc/resolver" + + "github.com/go-kratos/kratos/v2/registry" ) type testClientConn struct { diff --git a/transport/grpc/server_test.go b/transport/grpc/server_test.go index fd1ae6757..4db44fe95 100644 --- a/transport/grpc/server_test.go +++ b/transport/grpc/server_test.go @@ -11,12 +11,13 @@ import ( "testing" "time" + "google.golang.org/grpc" + "github.com/go-kratos/kratos/v2/errors" "github.com/go-kratos/kratos/v2/internal/matcher" pb "github.com/go-kratos/kratos/v2/internal/testdata/helloworld" "github.com/go-kratos/kratos/v2/middleware" "github.com/go-kratos/kratos/v2/transport" - "google.golang.org/grpc" ) // server is used to implement helloworld.GreeterServer. diff --git a/transport/grpc/transport.go b/transport/grpc/transport.go index 866228d1d..50ca5c91d 100644 --- a/transport/grpc/transport.go +++ b/transport/grpc/transport.go @@ -1,9 +1,10 @@ package grpc import ( + "google.golang.org/grpc/metadata" + "github.com/go-kratos/kratos/v2/selector" "github.com/go-kratos/kratos/v2/transport" - "google.golang.org/grpc/metadata" ) var _ transport.Transporter = (*Transport)(nil) diff --git a/transport/http/binding/encode_test.go b/transport/http/binding/encode_test.go index a06a25d23..7e8286c90 100644 --- a/transport/http/binding/encode_test.go +++ b/transport/http/binding/encode_test.go @@ -3,8 +3,9 @@ package binding import ( "testing" - "github.com/go-kratos/kratos/v2/internal/testdata/binding" "google.golang.org/protobuf/types/known/fieldmaskpb" + + "github.com/go-kratos/kratos/v2/internal/testdata/binding" ) func TestProtoPath(t *testing.T) { diff --git a/transport/http/context.go b/transport/http/context.go index f65e03fb4..347d7f2b7 100644 --- a/transport/http/context.go +++ b/transport/http/context.go @@ -9,10 +9,11 @@ import ( "net/url" "time" + "github.com/gorilla/mux" + "github.com/go-kratos/kratos/v2/middleware" "github.com/go-kratos/kratos/v2/transport" "github.com/go-kratos/kratos/v2/transport/http/binding" - "github.com/gorilla/mux" ) var _ Context = (*wrapper)(nil)