changeset 1345:6a021108410b

Finished the doc strings for the common package.
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Mon, 26 Nov 2018 11:30:28 +0100
parents 9e0beb373690
children 474e95475832
files pkg/common/errors.go pkg/common/random.go pkg/common/zip.go
diffstat 3 files changed, 8 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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 {
--- 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 (
--- 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 {