MCPcopy Create free account
hub / github.com/bufbuild/buf / PackageToNameToService

Function PackageToNameToService

private/bufpkg/bufprotosource/bufprotosource.go:1014–1032  ·  view source on GitHub ↗

PackageToNameToService maps the Services in the Files to a map from package to name to Service. Returns error if the Services do not have unique names within the packages, which should generally never happen for properly-formed Files.

(files ...File)

Source from the content-addressed store, hash-verified

1012// Returns error if the Services do not have unique names within the packages,
1013// which should generally never happen for properly-formed Files.
1014func PackageToNameToService(files ...File) (map[string]map[string]Service, error) {
1015 packageToNameToService := make(map[string]map[string]Service)
1016 for _, file := range files {
1017 pkg := file.Package()
1018 nameToService, ok := packageToNameToService[pkg]
1019 if !ok {
1020 nameToService = make(map[string]Service)
1021 packageToNameToService[pkg] = nameToService
1022 }
1023 for _, service := range file.Services() {
1024 name := service.Name()
1025 if _, ok := nameToService[name]; ok {
1026 return nil, fmt.Errorf("duplicate service in package %q: %q", pkg, name)
1027 }
1028 nameToService[name] = service
1029 }
1030 }
1031 return packageToNameToService, nil
1032}
1033
1034// PackageToDirectlyImportedPackageToFileImports maps packages to directly imported packages
1035// to the FileImports that import this package.

Callers 1

Calls 3

PackageMethod · 0.65
ServicesMethod · 0.65
NameMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…