如何在Golang中添加/编辑文件元数据?

huangapple go评论96阅读模式
英文:

How to add/edit file metadata in Golang?

问题

我正在使用Go语言编写一个BitTorrent客户端,并希望通过将位图写入文件头/元数据来保存下载的进度。这样我就可以在下次开始下载时取消下载并从上次离开的地方重新开始。

然而,我找不到任何标准或第三方库可以让我写入文件元数据。我最接近的尝试是打印由os.Stat返回的FileInfo结构体。我不确定如何添加/编辑FileInfo结构体。

英文:

I am writing a Bittorrent client in Go and I would like to save the progress of the download by writing a bitfield to the file headers/metadata. This allows me to cancel the download and restart from where I left off the next time I start downloading.

However, I could not find any standard or third party libraries that allow me to write to file metadata. The closest I have gotten was printing the FileInfo struct returned by os.Stat. I am not sure how to add/edit the FileInfo struct.

答案1

得分: 3

我意识到在Golang中没有像那样的库函数,因为元数据是特定于文件系统的实现。所以,我决定将我的元数据隐藏在一个名为.filename.meta的隐藏文件中。

英文:

I realized there are no library functions in Golang like that because metadata is a filesystem specific implementation. So, I have decided to hide my metadata in a hidden file like .filename.meta

huangapple
  • 本文由 发表于 2016年11月15日 23:00:35
  • 转载请务必保留本文链接:https://go.coder-hub.com/40613067.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定