3

"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?

Amir Keibi
  • 1,991
  • 28
  • 45

1 Answers1

4

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.

itisravi
  • 3,406
  • 3
  • 23
  • 30