Skip to content
/ ifchanged Public

A simple Go module to run some code on demand if a file content has changed based on sha256 checksum, or if a file is missing. List of files can be also provided.

License

Notifications You must be signed in to change notification settings

zzwx/ifchanged

Repository files navigation

https://github.com/zzwx/ifchanged

Ifchanged

Package ifchanged is a collection of Go functions to perform callbacks in case of file changes (using sha256 hash) and / or missing files.

Use case: Generating css file only if scss file has changed or css file is missing.

Example

err = ifchanged.NewIf().
    Changed(fileName, fileName+".sha256").
    Missing("somefile.txt").
    Execute(func() error {
        fmt.Printf("This has been called because \"somefile.txt\" is missing or %v has changed\n", fileName)
        return nil
    })

Doc

pkg.go.dev/github.com/zzwx/ifchanged

Dependencies

  • go 1.13

DB

ifchanged, additionally, has a way to provide checksums using a DB interface.

About

A simple Go module to run some code on demand if a file content has changed based on sha256 checksum, or if a file is missing. List of files can be also provided.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages