From b002cbb49176b13e91face433a66b8e2d7c77e39 Mon Sep 17 00:00:00 2001 From: Vasiliy Tolstov Date: Tue, 23 Feb 2021 23:58:24 +0300 Subject: [PATCH] fixup imports Signed-off-by: Vasiliy Tolstov --- http.go | 23 +++++------------------ rpc.go | 21 ++++----------------- 2 files changed, 9 insertions(+), 35 deletions(-) diff --git a/http.go b/http.go index efe277d..391d2a9 100644 --- a/http.go +++ b/http.go @@ -30,26 +30,13 @@ func (g *Generator) httpGenerate(component string, plugin *protogen.Plugin) erro gfile.P("// Code generated by protoc-gen-micro") gfile.P("// source: ", *file.Proto.Name) gfile.P("package ", file.GoPackageName) - - gfile.P() - gfile.P("import (") - gfile.P(`"context"`) - gfile.P() - gfile.P(`micro_api "github.com/unistack-org/micro/v3/api"`) - gfile.P(`micro_client_http "github.com/unistack-org/micro-client-http/v3"`) - gfile.P(`micro_client "github.com/unistack-org/micro/v3/client"`) - gfile.P(`micro_server "github.com/unistack-org/micro/v3/server"`) - gfile.P(")") gfile.P() - gfile.P("// Reference imports to suppress errors if they are not otherwise used.") - gfile.P("var (") - gfile.P("_ ", "micro_api.Endpoint") - gfile.P("_ ", "context.Context") - gfile.P(" _ ", "micro_client.Option") - gfile.P(" _ ", "micro_server.Option") - gfile.P(")") - gfile.P() + gfile.Import(contextPackage) + gfile.Import(microApiPackage) + gfile.Import(microClientPackage) + gfile.Import(microClientHttpPackage) + gfile.Import(microServerPackage) for _, service := range file.Services { generateServiceClient(gfile, service) diff --git a/rpc.go b/rpc.go index 4b09b9d..6d99932 100644 --- a/rpc.go +++ b/rpc.go @@ -19,25 +19,12 @@ func (g *Generator) rpcGenerate(component string, plugin *protogen.Plugin) error gfile.P("// Code generated by protoc-gen-micro") gfile.P("// source: ", *file.Proto.Name) gfile.P("package ", file.GoPackageName) - - gfile.P() - gfile.P("import (") - gfile.P(`"context"`) - gfile.P() - gfile.P(`micro_api "github.com/unistack-org/micro/v3/api"`) - gfile.P(`micro_client "github.com/unistack-org/micro/v3/client"`) - gfile.P(`micro_server "github.com/unistack-org/micro/v3/server"`) - gfile.P(")") gfile.P() - gfile.P("// Reference imports to suppress errors if they are not otherwise used.") - gfile.P("var (") - gfile.P("_ ", "micro_api.Endpoint") - gfile.P("_ ", "context.Context") - gfile.P(" _ ", "micro_client.Option") - gfile.P(" _ ", "micro_server.Option") - gfile.P(")") - gfile.P() + gfile.Import(contextPackage) + gfile.Import(microApiPackage) + gfile.Import(microClientPackage) + gfile.Import(microServerPackage) for _, service := range file.Services { generateServiceClient(gfile, service)