gowizzard / baraddur

A small and extreme lightweight file-watcher.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Barad-dûr

GitHub go.mod Go version of a Go module Go CodeQL CompVer Go Reference Go Report Card GitHub issues GitHub forks GitHub stars GitHub license

This is a small and very lightweight file watcher that can also be used in docker projects. With this file watcher you can watch different files, set the interval of the check and define in a function what should happen with a new mod time of the file.

Install

First you have to install the package. You can do this as follows:

go get github.com/gowizzard/baraddur

How to use

Here you can find an example of how to use the function. You can define multiple files. For each file you can define the path, the interval of the check and the function to be executed in case of a new modification. It is also possible to define what should happen if an error occurs.

c := baraddur.Config{
    Files: []baraddur.File{
        {
            Path:     "config.go",
            Interval: 1 * time.Second,
            Fault: func(err error) {
                log.Fatalln(err)
            },
            Execute: func() {
                log.Println("Update!")
            },
        },
    },
}

c.Watch()

Special thanks

Thanks to JetBrains for supporting me with this and other open source projects.

About

A small and extreme lightweight file-watcher.

License:MIT License


Languages

Language:Go 97.1%Language:Makefile 2.9%