type Package … type ImportRestriction … // ForbiddenImportsFor determines all of the forbidden // imports for a package given the import restrictions func (i *ImportRestriction) ForbiddenImportsFor(pkg Package) ([]string, error) { … } // isRestrictedDir determines if the source directory has // any restrictions placed on it by this configuration. // A path will be restricted if: // - it falls under the base import path // - it does not fall under any of the ignored sub-trees func (i *ImportRestriction) isRestrictedDir(dir string) (bool, error) { … } // isPathUnder determines if path is under base func isPathUnder(base, path string) (bool, error) { … } // forbiddenImportsFor determines all of the forbidden // imports for a package given the import restrictions // and returns a deduplicated list of them func (i *ImportRestriction) forbiddenImportsFor(pkg Package) []string { … } // isForbidden determines if an import is forbidden, // which is true when the import is: // - of a package under the rootPackage // - is not of the base import path or a sub-package of it // - is not of an allowed path or a sub-package of one func (i *ImportRestriction) isForbidden(imp string) bool { … } var rootPackage … func main() { … } func loadImportRestrictions(configFile string) ([]ImportRestriction, error) { … } func resolvePackageTree(treeBase string) ([]Package, error) { … } func decodePackages(r io.Reader) ([]Package, error) { … } func logForbiddenPackages(base string, forbidden []string) { … }