Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add/edit file metadata in Golang?

Tags:

go

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.

like image 833
1729 Avatar asked Nov 29 '25 04:11

1729


1 Answers

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

like image 197
1729 Avatar answered Nov 30 '25 23:11

1729