Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import (
- "os"
- "path/filepath"
- "time"
- )
- const NUM_WORKERS = 5
- var sourceFileChan = make(chan SourceFile)
- type SourceFile struct {
- Path string
- Date string
- PresetID int
- }
- func listFunc(path string, file os.FileInfo, err error) error {
- if err != nil {
- println("ERROR BLYA", err.Error())
- }
- source := SourceFile{Path: path}
- sourceFileChan <- source
- return nil
- }
- func converter() {
- for conv := range sourceFileChan {
- println("Имитация бурной деятельности ", conv.Path)
- time.Sleep(5 * time.Second)
- }
- }
- func main() {
- for i := 0; i < NUM_WORKERS; i++ {
- go converter()
- }
- for {
- filepath.Walk(os.Args[1], listFunc)
- time.Sleep(1 * time.Second)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement