Created
August 1, 2017 01:06
-
-
Save hyounggyu/3d55f9e16d1e465aba6a678e68a1d366 to your computer and use it in GitHub Desktop.
Disk usage using Go
This file contains 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
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