func TestUnlock(t *testing.T) { for _, c := range unlockTests { if out := filelocker.Unlock(c.in); out != c.expected { t.Errorf("Unlock(%v) = %v, expected %v", c.in, c.expected, out) } } }
func main() { fromDir := "/Users/bfarah1/Desktop/example/1" toDir := "/Users/bfarah1/Desktop/example/2" w := filewatcher.New(fromDir, func(f string) string { toLocation := path.Join(toDir, path.Base(f)) os.Rename(f, toLocation) unlocked := filelocker.Unlock(toLocation) time.Sleep(1 * time.Second) return "Moved " + unlocked }) w.Start() fmt.Println(<-w.Pulse) }