From 0fd48dc60ef8f2677c2a43bb2046930248390321 Mon Sep 17 00:00:00 2001 From: Guilhem Lettron Date: Thu, 12 Dec 2013 16:51:48 +0100 Subject: [PATCH] fix return for old go version --- uniuri.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/uniuri.go b/uniuri.go index 5296a30..0519336 100644 --- a/uniuri.go +++ b/uniuri.go @@ -51,6 +51,8 @@ func NewLenChars(length int, chars []byte) string { clen := byte(len(chars)) maxrb := byte(256 - (256 % len(chars))) i := 0 + var ret string + OuterLoop: for { if _, err := io.ReadFull(rand.Reader, r); err != nil { panic("error reading from random source: " + err.Error()) @@ -63,8 +65,10 @@ func NewLenChars(length int, chars []byte) string { b[i] = chars[c%clen] i++ if i == length { - return string(b) + ret = string(b) + break OuterLoop } } } + return ret }