fixup imports

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
Василий Толстов 2021-02-23 23:58:24 +03:00
parent 6b8fa89a69
commit b002cbb491
2 changed files with 9 additions and 35 deletions

23
http.go
View File

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

21
rpc.go
View File

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