use helper to detect import paths
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
20
micro.go
20
micro.go
@@ -14,28 +14,16 @@ func (g *Generator) microGenerate(component string, plugin *protogen.Plugin) err
|
||||
}
|
||||
|
||||
gname := file.GeneratedFilenamePrefix + "_" + component + ".pb.go"
|
||||
gfile := plugin.NewGeneratedFile(gname, ".")
|
||||
gfile := plugin.NewGeneratedFile(gname, file.GoImportPath)
|
||||
|
||||
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(")")
|
||||
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(")")
|
||||
gfile.P()
|
||||
gfile.Import(contextPackage)
|
||||
gfile.Import(microApiPackage)
|
||||
gfile.Import(microClientPackage)
|
||||
|
||||
// generate services
|
||||
for _, service := range file.Services {
|
||||
|
Reference in New Issue
Block a user