Skip to content

Instantly share code, notes, and snippets.

@ha1t
Created October 23, 2015 11:37
Show Gist options
  • Save ha1t/8d51e10d63f10273483b to your computer and use it in GitHub Desktop.
Save ha1t/8d51e10d63f10273483b to your computer and use it in GitHub Desktop.
POSIX Only
ackage main
import "fmt"
import "syscall"
import "os"
func main() {
var stat syscall.Statfs_t
wd, _ := os.Getwd()
syscall.Statfs(wd, &stat)
// Available blocks * size per block = available space in bytes
disk_size := stat.Bavail * uint64(stat.Bsize)
fmt.Println(disk_size / 1024 / 1024 / 1024)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment