Return byte slice not string

This commit is contained in:
Tobie Morgan Hitchcock 2016-05-23 14:08:32 +01:00
parent 9085865e35
commit 54a13c049f

View file

@ -21,10 +21,10 @@ import (
var chars = []byte("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789") var chars = []byte("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789")
// New produces a random string of length n // New produces a random string of length n
func New(l int) string { func New(l int) []byte {
if l == 0 { if l == 0 {
return "" return nil
} }
i := 0 i := 0
@ -45,7 +45,7 @@ func New(l int) string {
b[i] = chars[c%t] b[i] = chars[c%t]
i++ i++
if i == l { if i == l {
return string(b) return b
} }
} }