func GetDBSize(dbname string) (size string, err error) { info, err := os.Stat(DataDir + "/" + dbname) if err != nil { return "", err } if !info.IsDir() { return "", ErrInvalidDir } cmd := exec.Command("du", DataDir+"/"+dbname, "-s", "-k") output, err := cmd.CombinedOutput() if err != nil { return "", errors.Append(err, errors.New(string(output))) } size = strings.TrimSpace(strings.Split(string(output), "\t")[0]) return size, nil }
func main() { err1 := errors.Wrap(Err1, Err2) err2 := errors.Append(Err2, Err1) fmt.Printf("%T: %v\n", err1, err1) fmt.Printf("%T: %v\n", err2, err2) }