Coder Social home page Coder Social logo

go-filesystem's Introduction

文件管理器

项目介绍

  • go 版本实现的文件管理器

适配器

  • local: 本地存储

下载安装

go get -u github.com/deatil/go-filesystem

示例

import (
    "github.com/deatil/go-filesystem/filesystem"
    localAdapter "github.com/deatil/go-filesystem/filesystem/adapter/local"
)

func goFilesystem() {
    // 根目录
    root := "/storage"
    adapter := localAdapter.New(root)

    // 磁盘
    fs := filesystem.New(adapter)

    // 使用
    fs.Write(path string, contents string) (bool, error)
}

常用方法

// 写入
fs.Write(path, contents string) (bool, error)

// 写入数据流
fs.WriteStream(path string, resource io.Reader) (bool, error)

// 添加数据
fs.Put(path, contents string) (bool, error)

// 添加数据流
fs.PutStream(path string, resource io.Reader) (bool, error)

// 读取后删除
fs.ReadAndDelete(path string) (any, error)

// 更新
fs.Update(path, contents string) (bool, error)

// 读取
fs.Read(path string) (string, error)

// 重命名
fs.Rename(path, newpath string) (bool, error)

// 复制
fs.Copy(path, newpath string) (bool, error)

// 删除
fs.Delete(path string) (bool, error)

// 删除文件夹
fs.DeleteDir(dirname string) (bool, error)

// 创建文件夹
fs.CreateDir(dirname string) (bool, error)

// 列出内容
fs.ListContents(dirname string) ([]map[string]any, error)

开源协议

  • go-filesystem 文件管理器 遵循 Apache2 开源协议发布,在保留本软件版权的情况下提供个人及商业免费使用。

版权

go-filesystem's People

Contributors

deatil 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.