|
|
|
@ -31,7 +31,13 @@ func generateFile(gen *protogen.Plugin, file *protogen.File, omitempty bool) *pr |
|
|
|
|
g := gen.NewGeneratedFile(filename, file.GoImportPath) |
|
|
|
|
g.P("// Code generated by protoc-gen-go-http. DO NOT EDIT.") |
|
|
|
|
g.P("// versions:") |
|
|
|
|
g.P(fmt.Sprintf("// protoc-gen-go-http %s", release)) |
|
|
|
|
g.P(fmt.Sprintf("// - protoc-gen-go-http %s", release)) |
|
|
|
|
g.P("// - protoc ", protocVersion(gen)) |
|
|
|
|
if file.Proto.GetOptions().GetDeprecated() { |
|
|
|
|
g.P("// ", file.Desc.Path(), " is a deprecated file.") |
|
|
|
|
} else { |
|
|
|
|
g.P("// source: ", file.Desc.Path()) |
|
|
|
|
} |
|
|
|
|
g.P() |
|
|
|
|
g.P("package ", file.GoPackageName) |
|
|
|
|
g.P() |
|
|
|
@ -301,4 +307,16 @@ func isASCIIDigit(c byte) bool { |
|
|
|
|
return '0' <= c && c <= '9' |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func protocVersion(gen *protogen.Plugin) string { |
|
|
|
|
v := gen.Request.GetCompilerVersion() |
|
|
|
|
if v == nil { |
|
|
|
|
return "(unknown)" |
|
|
|
|
} |
|
|
|
|
var suffix string |
|
|
|
|
if s := v.GetSuffix(); s != "" { |
|
|
|
|
suffix = "-" + s |
|
|
|
|
} |
|
|
|
|
return fmt.Sprintf("v%d.%d.%d%s", v.GetMajor(), v.GetMinor(), v.GetPatch(), suffix) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const deprecationComment = "// Deprecated: Do not use." |
|
|
|
|