A tiny cross-platform Go library to hide or unhide files and directories.
Supported OSs: All unix based OSs (Tested on Ubuntu, MacOS), Windows
$ go get github.com/dastoori/higgs
package main
import (
"fmt"
"github.com/dastoori/higgs"
)
func main() {
path := "foo.txt"
// Hiding a file
newPath, err := higgs.Hide(path)
// NOTE: On Unix after hiding the file the file name
// will be changed to `.foo.txt` and `newPath` contains
// the new file name
if err != nil {
fmt.Println(err)
}
// Unhiding a file
newPath, err = higgs.Unhide(newPath)
if err != nil {
fmt.Println(err)
}
// Setting unix overwrite option (disable by default)
fh := NewFileHide(".bar.txt", UnixOverwriteOption(true))
// NOTE: On Unix if a `bar.txt` file exists, it will be
// overwritten after unhiding `.bar.txt`
err := fh.Unhide()
if err != nil {
fmt.Println(err)
}
// NOTE: `fh.Path` contains the new file name
}
MIT