Coder Social home page Coder Social logo

go-fs's Introduction

File Accessor For Go Inspired by NodeJs fs system

Build Status License Coverage Status Size

API almost like NodeJs fs module and fs-extra

Usage

go get https://github.com/axetroy/go-fs.git
import fs "github.com/axetroy/go-fs"

func main(){
  if err := fs.EnsureFile("./testFile.txt");err !=nill {

  }
  if err := fs.Copy("./testFile.txt", "./newTestFile.txt");err !=nil {

  }
}

Methods

Method Description
fs.EnsureFile(filepath string) Ensure the file exist, if not then create it
fs.WriteFile(filepath string, data []byte) Write file
fs.ReadFile(filepath string) Read file
fs.AppendFile(filepath string, data []byte) Append data into a file
fs.Truncate(filepath string, len int64) Truncate the file
fs.CreateReadStream(filepath string) Create a read stream (Reader)
fs.CreateWriteStream(filepath string) Create a write stream (Writer)
fs.EnsureDir(dir string) Ensure the dir exist, if not then create it
fs.Mkdir(dir string) Create a dir
fs.Readdir(dir string) Read a dir
fs.Mktemp(dir string, prefix string) Create a temp dir
fs.Rmdir(dir string) Remove a dir
fs.Stat(path string) Stat a file/dir
fs.LStat(path string) Stat a file/dir
fs.Remove(path string) Remove a file/dir
fs.PathExists(path string) Check a path is exist or not
fs.Link(existingPath string, newPath string) Link a file
fs.ReadLink(path string) Read link info
fs.Symlink(target string, path string) Create a Symlink
fs.Unlink(path string) Unlink a link
fs.Copy(src string, target string) Copy a file/dir
fs.Move(src string, target string) Move a file/dir
fs.Chmod(filepath string, mode os.FileMode) Change the file/dir's mode
fs.LChod(path string, uid int, gid int) Change the file/dir's mode
fs.ReadJson(filepath string) Read JSON file
fs.WriteJson(filepath string, data []byte) Write JSON file
fs.OuputFile(filepath string, data []byte) Almost the same as fs.WriteFile, except that if the directory does not exist, it's created.
fs.OuputJson(filepath string, data []byte) Almost the same as fs.WriteJson, except that if the directory does not exist, it's created.

Contributing

go get https://github.com/axetroy/go-fs.git
cd $GOPATH/src/github.com/axetroy/go-fs
go test -v

Contributing Guid

Test

go test -v

Contributors


Axetroy

๐Ÿ’ป ๐Ÿ› ๐ŸŽจ

License

FOSSA Status

go-fs's People

Contributors

axetroy avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

fossabot

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.