goFileName returns the output name for the generated Go file.
(pathType pathType)
| 292 | |
| 293 | // goFileName returns the output name for the generated Go file. |
| 294 | func (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 | |
| 317 | func (d *FileDescriptor) addExport(obj Object, sym symbol) { |
| 318 | d.exported[obj] = append(d.exported[obj], sym) |
no test coverage detected