func deleteBuckets(root bucket.Bucket, names []string) error { _, children, err := root.List() if err != nil { return fmt.Errorf("List: %s", err) } childMap := make(map[string]bool) for _, child := range children { childMap[child] = true } for _, name := range names { if _, ok := childMap[name]; !ok { fmt.Printf("\n%q not found. Skipping.\n", name) continue } child, err := root.Descend(name) if err != nil { return fmt.Errorf("Descend(%q): %s", name, err) } keys, children, err := child.List() if err != nil { return fmt.Errorf("List: %s", err) } fmt.Printf("\nGoing to delete %q:\n", name) for _, s := range summary(keys) { fmt.Println(" ", s) } for _, s := range summary(children) { fmt.Println(" ", s) } fmt.Printf("Continue? [y/N]: ") buf := bufio.NewReader(os.Stdin) line, err := buf.ReadString('\n') if err != nil { return fmt.Errorf("ReadString: %s", err) } if line == "" || (line[0] != 'y' && line[0] != 'Y') { fmt.Println("Delete cancelled!") return nil } err = child.Destroy() if err != nil { return fmt.Errorf("Destroy: %s", err) } fmt.Printf("Deleted %q\n", name) } return nil }