func (f *File) Register(c *sql.Collector) error {
	if f.c != nil {
		ok := prometheus.Unregister(f.c)
		logx.Debug.Println("Unregister:", ok)
		if !ok {
			return fmt.Errorf("failed to unregister %q", f.Name)
		}
		f.c = nil
	}
	err := prometheus.Register(c)
	if err != nil {
		return err
	}
	logx.Debug.Println("Register:", f.Name, c.RegisterErr)
	f.c = c
	return c.RegisterErr
}
Register the given collector. If a collector was previously registered with
this file, then it is unregistered first. If either registration or
unregister fails, then the error is returned.
package setup
import (
	"fmt"
	"log"
	"os"
	"github.com/m-lab/go/logx"
	"github.com/m-lab/prometheus-bigquery-exporter/sql"
	"github.com/prometheus/client_golang/prometheus"
	"github.com/spf13/afero"
)
var fs = afero.NewOsFs()
type File struct {
	Name string
	stat os.FileInfo
	c    *sql.Collector
}
func (f *File) IsModified() (bool, error) {
	var err error
	if f.stat == nil {
		f.stat, err = fs.Stat(f.Name)
		logx.Debug.Println("IsModified:stat1:", f.Name, err)
		return err == nil, err
	}
	curr, err := fs.Stat(f.Name)
	if err != nil {
		log.Printf("Failed to stat %q: %v", f.Name, err)
		return false, err
	}
	logx.Debug.Println("IsModified:stat2:", f.Name, curr.ModTime(), f.stat.ModTime(),
		curr.ModTime().After(f.stat.ModTime()))
	modified := curr.ModTime().After(f.stat.ModTime())
	if modified {
		f.stat = curr
	}
	return modified, nil
}