# HG changeset patch # User Sascha L. Teichmann # Date 1543228228 -3600 # Node ID 6a021108410b207dd228fe6e212e31ae01720352 # Parent 9e0beb3736904f58f2bf232c560f05b3640f84fc Finished the doc strings for the common package. diff -r 9e0beb373690 -r 6a021108410b pkg/common/errors.go --- a/pkg/common/errors.go Mon Nov 26 11:15:52 2018 +0100 +++ b/pkg/common/errors.go Mon Nov 26 11:30:28 2018 +0100 @@ -19,6 +19,7 @@ "strings" ) +// ToError concats a slice of errors to a single error. func ToError(errs []error) error { var b strings.Builder for i, err := range errs { diff -r 9e0beb373690 -r 6a021108410b pkg/common/random.go --- a/pkg/common/random.go Mon Nov 26 11:15:52 2018 +0100 +++ b/pkg/common/random.go Mon Nov 26 11:30:28 2018 +0100 @@ -21,6 +21,8 @@ "math/big" ) +// GenerateRandomKey generates a cryptographically secure random key +// of a given length. func GenerateRandomKey(length int) []byte { k := make([]byte, length) if _, err := io.ReadFull(rand.Reader, k); err != nil { @@ -29,6 +31,9 @@ return k } +// RandomString generates a cryptographically secure password +// of a given length which consists of alpha numeric characters +// and at least one 'special' one. func RandomString(n int) string { const ( diff -r 9e0beb373690 -r 6a021108410b pkg/common/zip.go --- a/pkg/common/zip.go Mon Nov 26 11:15:52 2018 +0100 +++ b/pkg/common/zip.go Mon Nov 26 11:30:28 2018 +0100 @@ -18,6 +18,8 @@ "strings" ) +// FindInZIP scans a ZIP file directory for a file that ends with +// case invariant string. Returns only the first match. func FindInZIP(z *zip.ReadCloser, needle string) *zip.File { needle = strings.ToLower(needle) for _, straw := range z.File {