我爱占星网 我爱占星网
首页
编程
java
php
前端
首页 编程 java php 前端

在GO中获取实际文件大小与表观大小

"fs.sys.Size" (fs being fileStat in the os package) returns the apparent size of a file. This isn't ideal when dealing with sparse files.

Is there a way to get the actual file size in GO? Or all applications are bound to get the converted metadata that represent empty blocks as real ones?

Looks like the Stat_t structure filled using stat/fstat calls from the Syscall package is all you need. Just multiply Blocks by 512 to get the disk space consumed.

近期文章

  • 如何正确解组命令行输入?
  • Docker在完成Golang项目构建之前退出
  • 如何在Go中将SVG直接包含为html部分
  • 大数据率竞赛
  • 从Redigo调用lua脚本抛出错误的args错误
  • Golang-传递和返回变量的最佳做法
  • 如何使用Golang在DSE图中创建图遍历
  • net.IPNet内其他net.IPNet?
  • 如何从剪贴板存储器(uintptr)检索图像数据缓冲区?
  • 通过aws-sdk-go签名URL时,签名不匹配403错误
  • 需要使用mgo投影嵌套数组
  • 转到模板-检查json列表中是否存在密钥
  • Golang。 惊慌类型
  • 从函数获取响应而不返回-Golang
  • 如何正确停止Go SDK随附的网络服务器?
  • 如何在Golang中正确初始化结构体中的结构体指针
  • 如何在GO中为不同路径使用不同的中间件?
  • Govendor作为类型错误
  • 具有多个参数的过滤器结构
  • 更新更新请求中的某些值

Copyright ©2022 我爱占星 All Rights Reserved.

浙ICP备2022030071号-1

部分图文来自网络,如有侵犯您的版权,请告诉我们删除

友情链接:代码精华