MCPcopy
hub / github.com/golang/protobuf / goFileName

Method goFileName

protoc-gen-go/generator/generator.go:294–315  ·  view source on GitHub ↗

goFileName returns the output name for the generated Go file.

(pathType pathType)

Source from the content-addressed store, hash-verified

292
293// goFileName returns the output name for the generated Go file.
294func (d *FileDescriptor) goFileName(pathType pathType) string {
295 name := *d.Name
296 if ext := path.Ext(name); ext == ".proto" || ext == ".protodevel" {
297 name = name[:len(name)-len(ext)]
298 }
299 name += ".pb.go"
300
301 if pathType == pathTypeSourceRelative {
302 return name
303 }
304
305 // Does the file have a "go_package" option?
306 // If it does, it may override the filename.
307 if impPath, _, ok := d.goPackageOption(); ok && impPath != "" {
308 // Replace the existing dirname with the declared import path.
309 _, name = path.Split(name)
310 name = path.Join(string(impPath), name)
311 return name
312 }
313
314 return name
315}
316
317func (d *FileDescriptor) addExport(obj Object, sym symbol) {
318 d.exported[obj] = append(d.exported[obj], sym)

Callers 1

GenerateAllFilesMethod · 0.80

Calls 1

goPackageOptionMethod · 0.95

Tested by

no test coverage detected