go - 创建 tar 时避免父文件夹结构
问题描述
https://github.com/mimoo/eureka/blob/master/folders.go
我正在使用上面链接中给出的压缩方法在 Golang 中创建具有递归文件夹结构的 Tar。
现在,说如果我给/home/Documents/project
作为 src
然后,创建的 tar 还包含 /home/Documents/project/files
我想避免这里的父文件夹结构。
前任。tar 应直接包含:files
如何修改此方法以实现此目的?
提前致谢。
解决方案
一个不修改代码的棘手方法,如果你的程序没有并发逻辑,你可以这样做:
os.Chdir("/home/Documents/project")
compress("./", output)
推荐阅读
- flutter - 如何在飞镖中制作超级构造函数
- c++ - 一起使用 new 和 & 符号
- java - PDF 垂直剪切并合并
- swiftui - SwiftUI - 开始/结束外观转换的不平衡调用
- reactjs - React Native Deck Swiper
- go - 在 Windows 中用另一个版本替换 go-swagger
- cryptography - 格式化 Chainlink AggregatorV3Interface 对美元的“答案”?
- python - Django - 如何区分数据库中的用户?
- jaeger - 如何配置 Jaeger 代理以将跟踪信息发送到另一台服务器上的收集器
- python - SQLDecodeError(err_key=tok.value, djongo.exceptions.SQLDecodeError