github.com/dastoori/higgs

A tiny cross-platform Go library to hide/unhide files and directories


Keywords
directory, file, file-handling, fs, go, golang, hidden, hidden-files, hide, hide-files, hide-folder, higgs, macos, ubuntu, unix, windows
License
MIT
Install
go get github.com/dastoori/higgs

Documentation

higgs

A tiny cross-platform Go library to hide or unhide files and directories.

Supported OSs: All unix based OSs (Tested on Ubuntu, MacOS), Windows

unix windows codecov GitHub release
Go Reference GitHub go.mod Go version Go Report Card GitHub Mentioned in Awesome Go

Installation

$ go get github.com/dastoori/higgs

Usage

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
}

License

MIT