go-filesystem 文件管理器
go-filesystem 文件管理器
- go 版本实现的文件管理器
- 项目地址:github.com/deatil/go-filesystem
适配器
local
: 本地存储
安装
go get github.com/deatil/go-filesystem
示例
import (
"github.com/deatil/go-filesystem/filesystem"
localAdapter "github.com/deatil/go-filesystem/filesystem/adapter/local"
)
func init() {
// 根目录
root := "/storage"
adapter := localAdapter.New(root)
// 配置
adapterConf := make(map[string]interface{})
// 磁盘
fs := filesystem.New(adapter, adapterConf)
// 使用
fs.Write(path string, contents string) bool
}
常用方法
// 写入
fs.Write(path, contents string) bool
// 添加数据
fs.Put(path, contents string) bool
// 读取后删除
fs.ReadAndDelete(path string) (interface{}, error)
// 更新
fs.Update(path, contents string) bool
// 读取
fs.Read(path string) interface{}
// 重命名
fs.Rename(path, newpath string) bool
// 复制
fs.Copy(path, newpath string) bool
// 删除
fs.Delete(path string) bool
// 删除文件夹
fs.DeleteDir(dirname string) bool
// 创建文件夹
fs.CreateDir(dirname string) bool
// 列出内容
fs.ListContents(dirname string) bool
相关推荐
通用后台管理系统: lakego-admin
本作品采用《CC 协议》,转载必须注明作者和本文链接
推荐文章: