Skip to content

Instantly share code, notes, and snippets.

@223n

223n/code.go

Created May 24, 2017
Embed
What would you like to do?
Goで指定したフォルダのサイズを求めようとしていた
package main
import (
"fmt"
"os"
"path/filepath"
)
func main() {
value, _ := DirSize("\\\\nas1101\\Users")
fmt.Println(value)
}
func DirSize(path string) (int64, error) {
var size int64
err := filepath.Walk(path, func(_ string, info os.FileInfo, err error) error {
if !info.IsDir() {
size += info.Size()
}
return err
})
return size, err
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.