From 19ed4da161192796cc56eca87e760a56621a139d Mon Sep 17 00:00:00 2001 From: Winni Neessen Date: Sat, 20 Mar 2021 22:18:16 +0100 Subject: [PATCH] Minor changes --- apg.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apg.go b/apg.go index fe15917..8595d2a 100644 --- a/apg.go +++ b/apg.go @@ -4,7 +4,6 @@ import ( "crypto/rand" "flag" "fmt" - "log" "math/big" "os" "regexp" @@ -119,7 +118,7 @@ func main() { func getRandChar(charRange *string, pwLength int) string { availCharsLength := len(*charRange) charSlice := []byte(*charRange) - returnString := []byte{} + returnString := make([]byte, pwLength) for i := 0; i < pwLength; i++ { randNum := getRandNum(availCharsLength) returnString = append(returnString, charSlice[randNum]) @@ -131,7 +130,8 @@ func getRandNum(maxNum int) int { maxNumBigInt := big.NewInt(int64(maxNum)) randNum64, err := rand.Int(rand.Reader, maxNumBigInt) if err != nil { - log.Fatalf("An error occured generating random number: %v", err) + fmt.Printf("An error occured while generating random number: %v", err) + os.Exit(1) } randNum := int(randNum64.Int64()) return randNum