func expandGlobs(client *hdfs.Client, globbedPath string) ([]string, error) {
	parts := strings.Split(globbedPath, "/")[1:]
	var res []string
	var splitAt int

	for splitAt = range parts {
		if hasGlob(parts[splitAt]) {
			break
		}
	}

	var base, glob, next, remainder string
	base = "/" + path.Join(parts[:splitAt]...)
	glob = parts[splitAt]

	if len(parts) > splitAt+1 {
		next = parts[splitAt+1]
		remainder = path.Join(parts[splitAt+2:]...)
	} else {
		next = ""
		remainder = ""
	}

	list, err := client.ReadDir(base)
	if err != nil {
		return nil, err
	}

	for _, fi := range list {
		match, _ := path.Match(glob, fi.Name())
		if !match {
			continue
		}

		newPath := path.Join(base, fi.Name(), next, remainder)
		if hasGlob(newPath) {
			if fi.IsDir() {
				children, err := expandGlobs(client, newPath)
				if err != nil {
					//return nil, err
					continue
				}

				res = append(res, children...)
			}
		} else {
			_, err := client.Stat(newPath)
			if os.IsNotExist(err) {
				continue
			} else if err != nil {
				return nil, err
			}

			res = append(res, newPath)
		}
	}

	return res, nil
}
// expandGlobs recursively expands globs in a filepath. It assumes the paths
// are already cleaned and normalized (ie, absolute).
expandGlobs recursively expands globs in a filepath. It assumes the paths
are already cleaned and normalized .
// expandGlobs recursively expands globs in a filepath . It assumes the paths // are already cleaned and normalized ( ie absolute ) .
func expandGlobs(client *hdfs.Client, globbedPath string) ([]string, error) {
	parts := strings.Split(globbedPath, "/")[1:]
	var res []string
	var splitAt int
	for splitAt = range parts {
		if hasGlob(parts[splitAt]) {
			break
		}
	}
	var base, glob, next, remainder string
	base = "/" + path.Join(parts[:splitAt]...)
	glob = parts[splitAt]
	if len(parts) > splitAt+1 {
		next = parts[splitAt+1]
		remainder = path.Join(parts[splitAt+2:]...)
	} else {
		next = ""
		remainder = ""
	}
	list, err := client.ReadDir(base)
	if err != nil {
		return nil, err
	}
	for _, fi := range list {
		match, _ := path.Match(glob, fi.Name())
		if !match {
			continue
		}
		newPath := path.Join(base, fi.Name(), next, remainder)
		if hasGlob(newPath) {
			if fi.IsDir() {
				children, err := expandGlobs(client, newPath)
				if err != nil {
					continue
				}
				res = append(res, children...)
			}
		} else {
			_, err := client.Stat(newPath)
			if os.IsNotExist(err) {
				continue
			} else if err != nil {
				return nil, err
			}
			res = append(res, newPath)
		}
	}
	return res, nil
}
func expandGlobs ( client * hdfs . Client , globbedPath string ) ( [ ] string , error ) { parts := strings . Split ( globbedPath , " " ) [ 1 : ] var res [ ] string var splitAt int for splitAt = range parts { if hasGlob ( parts [ splitAt ] ) { break } } var base , glob , next , remainder string base = " " + path . Join ( parts [ : splitAt ] ... ) glob = parts [ splitAt ] if len ( parts ) > splitAt + 1 { next = parts [ splitAt + 1 ] remainder = path . Join ( parts [ splitAt + 2 : ] ... ) } else { next = " " remainder = " " } list , err := client . ReadDir ( base ) if err != nil { return nil , err } for _ , fi := range list { match , _ := path . Match ( glob , fi . Name ( ) ) if ! match { continue } newPath := path . Join ( base , fi . Name ( ) , next , remainder ) if hasGlob ( newPath ) { if fi . IsDir ( ) { children , err := expandGlobs ( client , newPath ) if err != nil { continue } res = append ( res , children ... ) } } else { _ , err := client . Stat ( newPath ) if os . IsNotExist ( err ) { continue } else if err != nil { return nil , err } res = append ( res , newPath ) } } return res , nil }
expandGlobs recursively expands globs in a filepath.
expandGlobs recursively expands globs in a filepath .
//return nil, err