Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
“ fs.sys.Size ”(fs 是os包中的fileStat)返回文件的表观大小。这在处理稀疏文件时并不理想。
有没有办法在 GO 中获取实际文件大小?或者所有应用程序都必须获得将空块表示为真实块的转换后的元数据?
看起来您只需要使用Syscall 包中的 stat/fstat 调用填充 的Stat_t 结构。只需将 Blocks 乘以 512 即可获得消耗的磁盘空间。