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)
| 1012 | // Returns error if the Services do not have unique names within the packages, |
| 1013 | // which should generally never happen for properly-formed Files. |
| 1014 | func 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. |
no test coverage detected
searching dependent graphs…