Created
October 23, 2015 11:37
-
-
Save ha1t/8d51e10d63f10273483b to your computer and use it in GitHub Desktop.
POSIX Only
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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