英文:
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
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论