GithubHelp home page GithubHelp logo

fswatcher's Introduction

FSWATCHER

Build Status Go Report Card GoDoc

A library to listen to the changes of File/Folder:

  • CREATE
  • REMOVE
  • RENAME
  • DELETE

Installation

go get github.com/raomuyang/fswatcher/iusync

Watcher

Listen for changes to files or directories.

  • Directory: All subfiles and subdirectories are recursively monitored (the file at initialization is not processed).
  • File: only listen for changes to this file, and stop listening when the file is deleted.
package exapmle
import (
	"github.com/raomuyang/fswatcher"
	"time"
)

func demo() {
	callable := fswatcher.Callable{
		OnCreate: onCreateFunc,
		OnRename: onRenameFunc,
		OnWrite:  onWriteFunc,
		OnRemove: onRemoveFunc,
	}

	dw, err := fswatcher.Watch("/path/to/target/", callable)
	defer dw.Stop()

	if err != nil {
		panic(err)
	}
	
	<-time.After(time.Minute * 10)
}

iusync

A tool for synchronizing local files to cloud storage in real time. When you use Markdown to write a blog, you can easily sync the local image of the image to the map bed and get the image link.

Usage

  • install iusync by golang (You can also download the compiled executable binary file from release.)
go get github.com/raomuyang/fswatcher/iusync
  • write config
store_type: qiniu # qiniu / oss
log_level: 5 # DEBUG(5) INFO(4) WARN(3) ERROR(2) FATAL(1) PANIC(0)
log_path: /path/to/save/log # specify the log path
scan_at_start: true # default false
include_hidden: true # default false
opt_delay: 3 # default 3 (seconds)
access:
  access_key_id: your_access_key_id
  access_key_secret: your_access_key_secret
  bucket: your_bucket_name
  domain: http://eg.xxx.cn # The bound custom domain name(to assemble a visible url)
  endpoint: xxx  # if the store type is qiniu, this section is optional
  • run
iusync -target=/path/to/target/folder/or/image [-conf=specify/conf/file]

Future

  • file hook

fswatcher's People

Contributors

raomuyang avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

xuanyuanjx

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.