use helper to detect import paths
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
18
gorilla.go
18
gorilla.go
@@ -23,22 +23,18 @@ func (g *Generator) gorillaGenerate(component string, plugin *protogen.Plugin) e
|
||||
|
||||
gorillaPackageFiles[file.GoPackageName] = struct{}{}
|
||||
gname := "micro" + "_" + component + ".pb.go"
|
||||
gfile := plugin.NewGeneratedFile(gname, ".")
|
||||
gfile := plugin.NewGeneratedFile(gname, file.GoImportPath)
|
||||
|
||||
gfile.P("// Code generated by protoc-gen-micro")
|
||||
gfile.P("package ", file.GoPackageName)
|
||||
gfile.P()
|
||||
|
||||
gfile.P("import (")
|
||||
gfile.P(`"fmt"`)
|
||||
gfile.P(`"net/http"`)
|
||||
gfile.P(`"reflect"`)
|
||||
gfile.P(`"strings"`)
|
||||
gfile.P()
|
||||
gfile.P(`micro_api "github.com/unistack-org/micro/v3/api"`)
|
||||
gfile.P(`mux "github.com/gorilla/mux"`)
|
||||
gfile.P(")")
|
||||
gfile.P()
|
||||
gfile.Import(fmtPackage)
|
||||
gfile.Import(httpPackage)
|
||||
gfile.Import(reflectPackage)
|
||||
gfile.Import(stringsPackage)
|
||||
gfile.Import(microApiPackage)
|
||||
gfile.Import(gorillaMuxPackage)
|
||||
|
||||
gfile.P("func RegisterHandlers(r *mux.Router, h interface{}, eps []*micro_api.Endpoint) error {")
|
||||
gfile.P("v := reflect.ValueOf(h)")
|
||||
|
Reference in New Issue
Block a user