func selectPackage(dir, rel string, packageMap map[string]*Package) (*Package, error) {
	if len(packageMap) == 0 {
		return nil, nil
	}
	if len(packageMap) == 1 {
		for _, pkg := range packageMap {
			return pkg, nil
		}
	}
	defaultPackageName := strings.Replace(rel, "/", "_", -1)
	for _, pkg := range packageMap {
		if pkgName := goPackageName(pkg); pkgName != "" && pkgName == defaultPackageName {
			return pkg, nil
		}
	}
	return nil, fmt.Errorf("%s: directory contains multiple proto packages. Gazelle can only generate a proto_library for one package.", dir)
}
func selectPackage(dir, rel string, packageMap map[string]*Package) (*Package, error) {
	if len(packageMap) == 0 {
		return nil, nil
	}
	if len(packageMap) == 1 {
		for _, pkg := range packageMap {
			return pkg, nil
		}
	}
	defaultPackageName := strings.Replace(rel, "/", "_", -1)
	for _, pkg := range packageMap {
		if pkgName := goPackageName(pkg); pkgName != "" && pkgName == defaultPackageName {
			return pkg, nil
		}
	}
	return nil, fmt.Errorf("%s: directory contains multiple proto packages. Gazelle can only generate a proto_library for one package.", dir)
}
func selectPackage ( dir , rel string , packageMap map [ string ] * Package ) ( * Package , error ) { if len ( packageMap ) == 0 { return nil , nil } if len ( packageMap ) == 1 { for _ , pkg := range packageMap { return pkg , nil } } defaultPackageName := strings . Replace ( rel , " " , " " , - 1 ) for _ , pkg := range packageMap { if pkgName := goPackageName ( pkg ) ; pkgName != " " && pkgName == defaultPackageName { return pkg , nil } } return nil , fmt . Errorf ( " " , dir ) }
// selectPackage chooses a package to generate rules for.
selectPackage chooses a package to generate rules for .