Source

devsrvr / compilation.go

Full commit
package main

import (
	"os"
	"path/filepath"
	"time"
)

// return the most recent modified time for any file
// in the given directory hierarchy
func SourceModifiedMoreRecentlyThan(root string, modtime time.Time) bool {
	mostRecentModTime := modtime
	filepath.Walk(root, func(path string, info os.FileInfo, err error) error {
		thistime := info.ModTime()
		if mostRecentModTime.After(modtime) {
			return filepath.SkipDir // don't bother
		}
		if thistime.After(modtime) {
			ext := filepath.Ext(info.Name())
			// TODO - make extensions configurable
			if ext == ".go" || ext == ".html" || ext == ".tmpl" {
				mostRecentModTime = thistime
			}
		}
		return nil
	})
	return mostRecentModTime.After(modtime)
}