MCPcopy Create free account
hub / github.com/CrunchyData/postgres-operator / accumulate

Function accumulate

internal/util/secrets.go:22–34  ·  view source on GitHub ↗

accumulate gathers n bytes from f and returns them as a string. It returns an empty string when f returns an error.

(n int, f func() (byte, error))

Source from the content-addressed store, hash-verified

20// accumulate gathers n bytes from f and returns them as a string. It returns
21// an empty string when f returns an error.
22func accumulate(n int, f func() (byte, error)) (string, error) {
23 result := make([]byte, n)
24
25 for i := range result {
26 if b, err := f(); err == nil {
27 result[i] = b
28 } else {
29 return "", err
30 }
31 }
32
33 return string(result), nil
34}
35
36// randomCharacter builds a function that returns random bytes from class.
37func randomCharacter(random io.Reader, class string) func() (byte, error) {

Callers 4

GenerateASCIIPasswordFunction · 0.85
TestAccumulateFunction · 0.85

Calls

no outgoing calls

Tested by 2

TestAccumulateFunction · 0.68