GithubHelp home page GithubHelp logo

vonwenm / go-file Goto Github PK

View Code? Open in Web Editor NEW

This project forked from caoimhechaos/go-file

0.0 2.0 0.0 212 KB

Slightly convenient and powerful Golang file API

License: BSD 3-Clause "New" or "Revised" License

Go 100.00%

go-file's Introduction

go-file

go-file essentially tries to provide a wrapper for file-like objects of different backend types. It uses URLs to identify files (be they local, in Doozer or somewhere else) and provide relatively transparent access to them.

At this point, it only supports watching files in different types of file systems, but there is support planned for implementing transparent access to readers and lateron even writers.

Watchers

So far, watchers are the only implemented common method. They can be used to watch files for changes and receive a callback with the file name and an io.ReadCloser object with the modified file contents for ease of access.

The basic important function is file.Watch(). It picks the correct handler for the URL type it's being passed and invokes it. The handler itself will do its thing in the background to ensure all modifications of the affected file are noticed and reported.

The callback itself will only see an io.ReadCloser interface to use when it's being notified of changes. This means that it doesn't require any logic relevant to the underlying file system implementation to get to the files contents.

Since the contents of the modified file may actually be irrelevant, implementations are required to ensure that just closing the file without reading it means that no nontrivial cost will be incurred; any expensive initialization should be deferred until the first call to Read().

go-file's People

Contributors

caoimhechaos avatar

Watchers

 avatar  avatar

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.