goPackageOption interprets the file's go_package option. If there is no go_package, it returns ("", "", false). If there's a simple name, it returns ("", pkg, true). If the option implies an import path, it returns (impPath, pkg, true).
()
| 273 | // If there's a simple name, it returns ("", pkg, true). |
| 274 | // If the option implies an import path, it returns (impPath, pkg, true). |
| 275 | func (d *FileDescriptor) goPackageOption() (impPath GoImportPath, pkg GoPackageName, ok bool) { |
| 276 | opt := d.GetOptions().GetGoPackage() |
| 277 | if opt == "" { |
| 278 | return "", "", false |
| 279 | } |
| 280 | // A semicolon-delimited suffix delimits the import path and package name. |
| 281 | sc := strings.Index(opt, ";") |
| 282 | if sc >= 0 { |
| 283 | return GoImportPath(opt[:sc]), cleanPackageName(opt[sc+1:]), true |
| 284 | } |
| 285 | // The presence of a slash implies there's an import path. |
| 286 | slash := strings.LastIndex(opt, "/") |
| 287 | if slash >= 0 { |
| 288 | return GoImportPath(opt), cleanPackageName(opt[slash+1:]), true |
| 289 | } |
| 290 | return "", cleanPackageName(opt), true |
| 291 | } |
| 292 | |
| 293 | // goFileName returns the output name for the generated Go file. |
| 294 | func (d *FileDescriptor) goFileName(pathType pathType) string { |
no test coverage detected