Need resource for worked examples for simple things

while true
    filename, event = watch_folder("/home/dave/tontine_2022/just_messing", 60)
    if !startswith(filename, ".goutputstream")
        println(filename, " => ", (event.changed ? "changed" :
                                   event.renamed ? "renamed" :
                                   event.timedout ? "timed out" :
                                   error("Unknown event"))
                                   )
    end
end

This will both skip the .goutputstream files, and print the file event as a readable string.

For more examples about using FileWatching, you could try this SourceGraph search of code that uses the package (though you’ll have to do a bit of digging yourself to see where exactly the functions are being used in the code).

Edit: changed github search to SourceGraph, results seem much better there

1 Like