1 Star 0 Fork 0

民禧农机/tools

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
go_naming.go 706 Bytes
一键复制 编辑 原始数据 按行查看 历史
surongzhen 提交于 2020-09-14 16:54 +08:00 . fix
package naming
import (
"path"
"github.com/golang/protobuf/protoc-gen-go/descriptor"
)
// GoFileName returns the output name for the generated Go file.
func GoFileName(f *descriptor.FileDescriptorProto, suffix string) string {
name := *f.Name
if ext := path.Ext(name); ext == ".pb" || ext == ".proto" || ext == ".protodevel" {
name = name[:len(name)-len(ext)]
}
name += suffix
// Does the file have a "go_package" option? If it does, it may override the
// filename.
if impPath, _, ok := goPackageOption(f); ok && impPath != "" {
// Replace the existing dirname with the declared import path.
_, name = path.Split(name)
name = path.Join(impPath, name)
return name
}
return name
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/surongzhen1213/tools.git
git@gitee.com:surongzhen1213/tools.git
surongzhen1213
tools
tools
v1.0.9

搜索帮助