From cf39a98cddcec5799e6e89651b07c25eb8406164 Mon Sep 17 00:00:00 2001 From: andreimarcu Date: Tue, 29 Sep 2015 22:12:02 -0400 Subject: [PATCH] Formatting --- util.go | 50 +++++++++++++++++++++++++------------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/util.go b/util.go index 5f210af..0512944 100644 --- a/util.go +++ b/util.go @@ -8,6 +8,31 @@ import ( // from http://stackoverflow.com/a/31832326 var src = rand.NewSource(time.Now().UnixNano()) +const letterBytes = "abcdefghijklmnopqrstuvwxyz1234567890" +const ( + letterIdxBits = 6 // 6 bits to represent a letter index + letterIdxMask = 1<= 0; { + if remain == 0 { + cache, remain = src.Int63(), letterIdxMax + } + if idx := int(cache & letterIdxMask); idx < len(letterBytes) { + b[i] = letterBytes[idx] + i-- + } + cache >>= letterIdxBits + remain-- + } + + return string(b) +} + var mimeToExtension = map[string]string{ "application/andrew-inset": "ez", "application/applixware": "aw", @@ -777,28 +802,3 @@ var mimeToExtension = map[string]string{ "video/x-smv": "smv", "x-conference/x-cooltalk": "ice", } - -const letterBytes = "abcdefghijklmnopqrstuvwxyz1234567890" -const ( - letterIdxBits = 6 // 6 bits to represent a letter index - letterIdxMask = 1<= 0; { - if remain == 0 { - cache, remain = src.Int63(), letterIdxMax - } - if idx := int(cache & letterIdxMask); idx < len(letterBytes) { - b[i] = letterBytes[idx] - i-- - } - cache >>= letterIdxBits - remain-- - } - - return string(b) -}