1
0
mirror of https://github.com/go-kratos/kratos.git synced 2025-01-16 02:47:03 +02:00

fix: fmt import (#2379)

This commit is contained in:
jesse.tang 2022-09-27 14:08:08 +08:00 committed by GitHub
parent 8d067a32db
commit 4d95050747
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
54 changed files with 108 additions and 54 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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