fix: fmt import (#2379)

pull/2408/head
jesse.tang 2 years ago committed by GitHub
parent 8d067a32db
commit 4d95050747
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      api/metadata/server.go
  2. 1
      cmd/kratos/internal/project/add.go
  3. 3
      cmd/kratos/internal/project/project.go
  4. 3
      cmd/protoc-gen-go-errors/errors.go
  5. 1
      config/file/watcher.go
  6. 1
      contrib/config/apollo/apollo.go
  7. 3
      contrib/config/consul/config.go
  8. 3
      contrib/config/consul/config_test.go
  9. 3
      contrib/config/consul/watcher.go
  10. 3
      contrib/config/etcd/config.go
  11. 3
      contrib/config/etcd/watcher.go
  12. 3
      contrib/config/kubernetes/config.go
  13. 3
      contrib/config/kubernetes/watcher.go
  14. 3
      contrib/config/nacos/watcher.go
  15. 3
      contrib/log/aliyun/aliyun.go
  16. 1
      contrib/log/fluent/fluent.go
  17. 3
      contrib/log/logrus/logrus.go
  18. 3
      contrib/log/logrus/logrus_test.go
  19. 3
      contrib/log/tencent/tencent.go
  20. 3
      contrib/log/zap/zap.go
  21. 3
      contrib/metrics/prometheus/counter.go
  22. 3
      contrib/metrics/prometheus/gauge.go
  23. 3
      contrib/metrics/prometheus/histogram.go
  24. 3
      contrib/metrics/prometheus/summary.go
  25. 3
      contrib/registry/consul/registry_test.go
  26. 3
      contrib/registry/discovery/discovery.go
  27. 3
      contrib/registry/etcd/registry.go
  28. 3
      contrib/registry/etcd/registry_test.go
  29. 3
      contrib/registry/etcd/watcher.go
  30. 3
      contrib/registry/kubernetes/registry.go
  31. 3
      contrib/registry/nacos/watcher.go
  32. 3
      contrib/registry/zookeeper/register_test.go
  33. 3
      contrib/registry/zookeeper/watcher.go
  34. 3
      encoding/json/json.go
  35. 3
      encoding/yaml/yaml.go
  36. 3
      errors/errors.go
  37. 1
      middleware/circuitbreaker/circuitbreaker.go
  38. 1
      middleware/ratelimit/ratelimit.go
  39. 3
      middleware/tracing/metadata.go
  40. 7
      middleware/tracing/span_test.go
  41. 3
      middleware/tracing/tracer.go
  42. 3
      middleware/tracing/tracer_test.go
  43. 5
      middleware/tracing/tracing.go
  44. 5
      middleware/tracing/tracing_test.go
  45. 3
      transport/grpc/balancer_test.go
  46. 3
      transport/grpc/client_test.go
  47. 5
      transport/grpc/codec.go
  48. 5
      transport/grpc/interceptor.go
  49. 3
      transport/grpc/resolver/discovery/builder_test.go
  50. 3
      transport/grpc/resolver/discovery/resolver_test.go
  51. 3
      transport/grpc/server_test.go
  52. 3
      transport/grpc/transport.go
  53. 3
      transport/http/binding/encode_test.go
  54. 3
      transport/http/context.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

@ -8,6 +8,7 @@ import (
"github.com/AlecAivazis/survey/v2"
"github.com/fatih/color"
"github.com/go-kratos/kratos/cmd/kratos/v2/internal/base"
)

@ -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.

@ -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 (

@ -6,6 +6,7 @@ import (
"path/filepath"
"github.com/fsnotify/fsnotify"
"github.com/go-kratos/kratos/v2/config"
)

@ -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"
)

@ -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.

@ -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"

@ -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 {

@ -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.

@ -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 {

@ -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.

@ -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 {

@ -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 {

@ -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

@ -8,6 +8,7 @@ import (
"time"
"github.com/fluent/fluent-logger-golang/fluent"
"github.com/go-kratos/kratos/v2/log"
)

@ -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)

@ -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) {

@ -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 {

@ -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)

@ -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)

@ -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)

@ -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)

@ -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)

@ -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) {

@ -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 {

@ -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 (

@ -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) {

@ -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)

@ -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

@ -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)

@ -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) {

@ -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)

@ -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.

@ -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.

@ -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 (

@ -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"

@ -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"
)

@ -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"

@ -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) {

@ -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

@ -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) {

@ -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.

@ -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)

@ -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) {

@ -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) {

@ -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() {

@ -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

@ -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) {

@ -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 {

@ -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.

@ -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)

@ -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) {

@ -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)

Loading…
Cancel
Save