Skip to content

Commit

Permalink
linting
Browse files Browse the repository at this point in the history
  • Loading branch information
aspacca committed Oct 26, 2024
1 parent 3cf1b3e commit b6a7f59
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
4 changes: 2 additions & 2 deletions server/handlers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func (s *suiteRedirectWithForceHTTPS) SetUpTest(c *C) {
c.Assert(err, IsNil)

handler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintln(w, "Hello, client")
_, _ = fmt.Fprintln(w, "Hello, client")
})

s.handler = srvr.RedirectHandler(handler)
Expand Down Expand Up @@ -83,7 +83,7 @@ func (s *suiteRedirectWithoutForceHTTPS) SetUpTest(c *C) {
c.Assert(err, IsNil)

handler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintln(w, "Hello, client")
_, _ = fmt.Fprintln(w, "Hello, client")
})

s.handler = srvr.RedirectHandler(handler)
Expand Down
5 changes: 4 additions & 1 deletion server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -402,12 +402,15 @@ func New(options ...OptionFn) (*Server, error) {
return s, nil
}

var theRand *rand.Rand

func init() {
var seedBytes [8]byte
if _, err := cryptoRand.Read(seedBytes[:]); err != nil {
panic("cannot obtain cryptographically secure seed")
}
rand.Seed(int64(binary.LittleEndian.Uint64(seedBytes[:])))

theRand = rand.New(rand.NewSource(int64(binary.LittleEndian.Uint64(seedBytes[:]))))
}

// Run starts Server
Expand Down
6 changes: 1 addition & 5 deletions server/token.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@ THE SOFTWARE.

package server

import (
"math/rand"
)

const (
// SYMBOLS characters used for short-urls
SYMBOLS = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
Expand All @@ -37,7 +33,7 @@ const (
func token(length int) string {
result := ""
for i := 0; i < length; i++ {
x := rand.Intn(len(SYMBOLS) - 1)
x := theRand.Intn(len(SYMBOLS) - 1)
result = string(SYMBOLS[x]) + result
}

Expand Down

0 comments on commit b6a7f59

Please sign in to comment.