fix: lint
continuous-integration/drone/push Build is passing Details

This commit is contained in:
kolaente 2023-03-05 22:24:25 +01:00
parent 4a82f3be3c
commit 9f14466dfa
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
2 changed files with 4 additions and 9 deletions

View File

@ -20,9 +20,7 @@ import (
"context" "context"
"encoding/json" "encoding/json"
"errors" "errors"
"math/rand"
"net/http" "net/http"
"time"
"code.vikunja.io/web/handler" "code.vikunja.io/web/handler"
@ -66,7 +64,7 @@ type claims struct {
} }
func init() { func init() {
rand.Seed(time.Now().UTC().UnixNano()) petname.NonDeterministicMode()
} }
func (p *Provider) setOicdProvider() (err error) { func (p *Provider) setOicdProvider() (err error) {

View File

@ -21,10 +21,6 @@ import (
"time" "time"
) )
func init() {
rand.Seed(time.Now().UnixNano())
}
const letterBytes = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" const letterBytes = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
const ( const (
letterIdxBits = 6 // 6 bits to represent a letter index letterIdxBits = 6 // 6 bits to represent a letter index
@ -34,11 +30,12 @@ const (
// MakeRandomString return a random string // MakeRandomString return a random string
func MakeRandomString(n int) string { func MakeRandomString(n int) string {
source := rand.New(rand.NewSource(time.Now().UnixNano()))
b := make([]byte, n) b := make([]byte, n)
// A rand.Int63() generates 63 random bits, enough for letterIdxMax letters! // A rand.Int63() generates 63 random bits, enough for letterIdxMax letters!
for i, cache, remain := n-1, rand.Int63(), letterIdxMax; i >= 0; { for i, cache, remain := n-1, source.Int63(), letterIdxMax; i >= 0; {
if remain == 0 { if remain == 0 {
cache, remain = rand.Int63(), letterIdxMax cache, remain = source.Int63(), letterIdxMax
} }
if idx := int(cache & letterIdxMask); idx < len(letterBytes) { if idx := int(cache & letterIdxMask); idx < len(letterBytes) {
b[i] = letterBytes[idx] b[i] = letterBytes[idx]