Loading main.go +16 −2 Original line number Diff line number Diff line Loading @@ -5,6 +5,8 @@ import ( "log" "path" "regexp" "runtime" "sync" "repositories.muehmer.net/boris.muehmer/sotatool/offline" ) Loading Loading @@ -32,12 +34,24 @@ func example01() { } // work on the file list numWorkers := runtime.NumCPU() filenames := make(chan string, numWorkers) var wg sync.WaitGroup for _, file := range files { if file.IsDir() { continue } if re.MatchString(file.Name()) { savegame.DumpJSONContents(path.Join(sourcedir, file.Name()), destdir) if re.MatchString(file.Name()) == false { continue } wg.Add(1) filenames <- file.Name() go func() { defer wg.Done() filename := <-filenames savegame.DumpJSONContents(path.Join(sourcedir, filename), destdir) }() } wg.Wait() } Loading
main.go +16 −2 Original line number Diff line number Diff line Loading @@ -5,6 +5,8 @@ import ( "log" "path" "regexp" "runtime" "sync" "repositories.muehmer.net/boris.muehmer/sotatool/offline" ) Loading Loading @@ -32,12 +34,24 @@ func example01() { } // work on the file list numWorkers := runtime.NumCPU() filenames := make(chan string, numWorkers) var wg sync.WaitGroup for _, file := range files { if file.IsDir() { continue } if re.MatchString(file.Name()) { savegame.DumpJSONContents(path.Join(sourcedir, file.Name()), destdir) if re.MatchString(file.Name()) == false { continue } wg.Add(1) filenames <- file.Name() go func() { defer wg.Done() filename := <-filenames savegame.DumpJSONContents(path.Join(sourcedir, filename), destdir) }() } wg.Wait() }