func keepOrder() {
	type inProgress struct {
		Path string
		Next *inProgress
	}
	var firstInProgress *inProgress
	for {
		select {
		case found := <-foundFiles:
			i := &inProgress{
				Path: found,
			}
			if firstInProgress == nil {
				firstInProgress = i
			} else {
				var cur *inProgress
				for cur = firstInProgress; cur.Next != nil; cur = cur.Next {
				}
				cur.Next = i
			}
		case finished := <-finishedFiles:
			var prev *inProgress
			for cur := firstInProgress; cur != nil; cur = cur.Next {
				if cur.Path == finished {
					if prev != nil {
						prev.Next = cur.Next
					} else {
						firstInProgress = cur.Next
					}
					break
				}
				prev = cur
			}
		case code := <-exit:
			if firstInProgress != nil {
				fmt.Println("the next file that needed processing was", firstInProgress.Path, "you can resume from there")
			}
			os.Exit(code)
		}
	}
}
needed to keep track of what's the next file in line that needs processing
because the workers can finish out of order, relative to the order
of the filesystem walk which uses inode order.
this ensures if you use skipUntil, it resumes from the right pos, without forgetting any
other files that also needed processing.
package main
import (
	"flag"
	"fmt"
	"github.com/influxdb/influxdb/client"
	"github.com/kisielk/whisper-go/whisper"
	"github.com/rcrowley/go-metrics"
	"log"
	"os"
	"path/filepath"
	"strings"
	"sync"
	"time"
)
var whisperDir string  
var influxWorkers, whisperWorkers int
var from, until uint
var fromTime, untilTime uint32
var influxWorkersWg, whisperWorkersWg sync.WaitGroup
var whisperFiles chan string
var foundFiles chan string
var finishedFiles chan string
var influxSeries chan *abstractSerie
var influxHost, influxUser, influxPass, influxDb string
var influxPort uint
var influxClient *client.Client
var whisperReadTimer metrics.Timer
var influxWriteTimer metrics.Timer
var skipUntil string
var skipCounter uint64
var influxPrefix string
var include, exclude string
var verbose bool
var all bool
var skipInfluxErrors bool
var skipWhisperErrors bool
var statsInterval uint
var exit chan int
func seriesString(s *client.Series) string {
	return fmt.Sprintf("InfluxDB series '%s' (%d points)", s.Name, len(s.Points))
}