I don't know how to change that.
I had an issue w/ the main routine ending before some of the worker routines were done so I saw incomplete results.
How do I tweak my logic so that I don't need a WaitGroup?
I forgot about my platform specific code. Here is the rest of that, that is in a file to be compiled on windows.
package main
import (
"fmt"
"os"
"path/filepath"
"strings"
) // Glob is case sensitive. I want case insensitive.
const estimatedNumberOfFiles = 100
func globCommandLineFiles(patterns []string) []string {
matchingNames := make([]string, 0, estimatedNumberOfFiles)
for _, pattern := range patterns {
matches, err := filepath.Glob(pattern) // Glob returns names of all files matching the case-sensitive pattern.
if err != nil {
fmt.Fprintln(os.Stderr, " Error from filepath.Glob is", err)
os.Exit(1)
} else if matches != nil { // At least one match
matchingNames = append(matchingNames, matches...)
}
}
return matchingNames
}
func commandLineFiles(patterns []string) []string {
workingDirname, err := os.Getwd()
if err != nil {
fmt.Fprintln(os.Stderr, "from commandlinefiles:", err)
return nil
}
dirEntries, e := os.ReadDir(workingDirname) // became available as of Go 1.16
if e != nil {
return nil
}
matchingNames := make([]string, 0, len(dirEntries))
for _, pattern := range patterns { // outer loop to test against multiple patterns.
for _, d := range dirEntries { // inner loop to test each pattern against the filenames.
if d.IsDir() {
continue // skip a subdirectory name
}
boolean, er := filepath.Match(pattern, strings.ToLower(d.Name()))
if er != nil {
fmt.Fprintln(os.Stderr, er)
continue
}
if boolean {
matchingNames = append(matchingNames, d.Name())
}
}
}
return matchingNames
}