Skip to content

Instantly share code, notes, and snippets.

@hyounggyu
Created August 1, 2017 01:06
Show Gist options
  • Save hyounggyu/3d55f9e16d1e465aba6a678e68a1d366 to your computer and use it in GitHub Desktop.
Save hyounggyu/3d55f9e16d1e465aba6a678e68a1d366 to your computer and use it in GitHub Desktop.
Disk usage using Go
package main
import (
"fmt"
"os"
"path/filepath"
"log"
)
func main() {
var tsize int64
tsize = 0
err := filepath.Walk(".", func(path string, info os.FileInfo, err error) error {
if !info.IsDir() {
tsize += info.Size()
}
return nil
})
if err != nil {
log.Fatal(err)
}
fmt.Printf("%d", tsize)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment