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

Method goPackageOption

protoc-gen-go/generator/generator.go:275–291  ·  view source on GitHub ↗

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).

()

Source from the content-addressed store, hash-verified

273// If there's a simple name, it returns ("", pkg, true).
274// If the option implies an import path, it returns (impPath, pkg, true).
275func (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.
294func (d *FileDescriptor) goFileName(pathType pathType) string {

Callers 3

goFileNameMethod · 0.95
WrapTypesMethod · 0.95
SetPackageNamesMethod · 0.80

Calls 2

GoImportPathTypeAlias · 0.85
cleanPackageNameFunction · 0.85

Tested by

no test coverage detected