Skip to content

Commit

Permalink
Properly call done on waitgroups
Browse files Browse the repository at this point in the history
  • Loading branch information
xbglowx committed Sep 14, 2021
1 parent 5a3fdb2 commit 76ff4f1
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions cmd/vault-kv-search.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,10 @@ func (vc *vaultClient) readLeafs(path string) {
fullPath := fmt.Sprintf("%s%s", path, dirEntry)
if strings.HasSuffix(dirEntry, "/") {
vc.wg.Add(1)
go vc.readLeafs(fullPath)
go func() {
defer vc.wg.Done()
vc.readLeafs(fullPath)
}()

} else {
secretInfo, err := vc.logical.Read(fullPath)
Expand All @@ -87,7 +90,6 @@ func (vc *vaultClient) readLeafs(path string) {
os.Exit(1)
}

//fmt.Printf("Searching against: %v\n", searchObjects)
if strings.Contains(valueStringType, vc.searchString) && searchObject == "value" {
fmt.Printf("Value match:\n\tSecret: %v\n\tKey: %v\n\tValue: %v\n", fullPath, key, value)
}
Expand All @@ -99,5 +101,4 @@ func (vc *vaultClient) readLeafs(path string) {
}
}
}
vc.wg.Done()
}

0 comments on commit 76ff4f1

Please sign in to comment.