feat: generate plugin version
This commit is contained in:
parent
d1f399b03d
commit
35eb0a9164
26
main.go
26
main.go
@ -4,16 +4,28 @@ import (
|
||||
"bytes"
|
||||
"flag"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/emicklei/proto"
|
||||
"gitter.top/common/protofmt"
|
||||
"google.golang.org/protobuf/compiler/protogen"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime/debug"
|
||||
"strings"
|
||||
)
|
||||
|
||||
var (
|
||||
version string
|
||||
)
|
||||
|
||||
func init() {
|
||||
info, ok := debug.ReadBuildInfo()
|
||||
if !ok {
|
||||
version = "unknown"
|
||||
return
|
||||
}
|
||||
version = info.Main.Version
|
||||
}
|
||||
|
||||
type Coco struct {
|
||||
DisableGenerateRouter bool // 禁止路由信息生成
|
||||
DisableGenerateMongoModel bool // 禁止mongo信息生成
|
||||
@ -109,7 +121,7 @@ func (c *Coco) generateRouterMap(plugin *protogen.Plugin) {
|
||||
g := plugin.NewGeneratedFile(filename, pbFile.GoImportPath)
|
||||
g.P("// Code generated by protoc-gen-coco. DO NOT EDIT.")
|
||||
g.P("// source: ", pbFile.GeneratedFilenamePrefix, ".proto")
|
||||
g.P("// generate at: ", time.Now().Format("2006-01-02 15:04:05"))
|
||||
g.P("// protoc-gen-coco: ", version)
|
||||
g.P()
|
||||
g.P("package ", pbFile.GoPackageName)
|
||||
g.P()
|
||||
@ -224,7 +236,7 @@ func (c *Coco) generateMongoModel(plugin *protogen.Plugin) {
|
||||
g := plugin.NewGeneratedFile(filename, pbFile.GoImportPath)
|
||||
g.P("// Code generated by protoc-gen-coco. DO NOT EDIT.")
|
||||
g.P("// source: ", pbFile.GeneratedFilenamePrefix, ".proto")
|
||||
g.P("// generate at: ", time.Now().Format("2006-01-02 15:04:05"))
|
||||
g.P("// protoc-gen-coco: ", version)
|
||||
g.P()
|
||||
g.P("package ", pbFile.GoPackageName)
|
||||
g.P()
|
||||
|
Loading…
Reference in New Issue
Block a user