From 089ff324e13caaa70942ae4b539833a4de561f4e Mon Sep 17 00:00:00 2001
From: Andrea Spacca <andrea.spacca@gmail.com>
Date: Mon, 28 Oct 2024 03:10:26 +0900
Subject: [PATCH] Check ci 20241026 (#632)

* bump go version and se gotip

* bump go version and se gotip

* bump go version and se gotip

* bump go version and se gotip

* linting

* gobin

* GOPATH
---
 .github/workflows/test.yml | 24 ++++++++++++++----------
 server/handlers_test.go    |  4 ++--
 server/server.go           |  5 ++++-
 server/token.go            |  6 +-----
 4 files changed, 21 insertions(+), 18 deletions(-)

diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 242bb8db..a6734362 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -13,9 +13,9 @@ jobs:
       fail-fast: false
       matrix:
         go_version:
-          - '1.18'
-          - '1.19'
-          - '1.20'
+          - '1.21'
+          - '1.22'
+          - '1.23'
           - tip
     name: Test with ${{ matrix.go_version }}
     steps:
@@ -29,16 +29,20 @@ jobs:
       - name: Install Go ${{ matrix.go_version }}
         if: ${{ matrix.go_version == 'tip' }}
         run: |
-          curl -sL https://storage.googleapis.com/go-build-snap/go/linux-amd64/$(git ls-remote https://github.com/golang/go.git HEAD | awk '{print $1;}').tar.gz -o gotip.tar.gz
-          ls -lah gotip.tar.gz
-          mkdir -p ~/sdk/gotip
-          tar -C ~/sdk/gotip -xzf gotip.tar.gz
-          echo "PATH=$HOME/go/bin:$HOME/sdk/gotip/bin/:$PATH" >> $GITHUB_ENV
-      - name: Vet and test
+          go install golang.org/dl/gotip@latest
+          `go env GOPATH`/bin/gotip download
+      - name: Vet and test no tip
+        if: ${{ matrix.go_version != 'tip' }}
         run: |
           go version
           go vet ./...
           go test ./...
+      - name: Vet and test gotip
+        if: ${{ matrix.go_version == 'tip' }}
+        run: |
+          `go env GOPATH`/bin/gotip version
+          `go env GOPATH`/bin/gotip vet ./...
+          `go env GOPATH`/bin/gotip test ./...
   golangci:
     name: Linting
     runs-on: ubuntu-latest
@@ -46,7 +50,7 @@ jobs:
       - uses: actions/checkout@v2
       - uses: actions/setup-go@master
         with:
-          go-version: '1.20'
+          go-version: '1.23'
           check-latest: true
       - name: golangci-lint
         uses: golangci/golangci-lint-action@v2
diff --git a/server/handlers_test.go b/server/handlers_test.go
index 2c76ffdf..f8f14ca1 100644
--- a/server/handlers_test.go
+++ b/server/handlers_test.go
@@ -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)
@@ -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)
diff --git a/server/server.go b/server/server.go
index 23eb5c35..b7a4e926 100644
--- a/server/server.go
+++ b/server/server.go
@@ -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
diff --git a/server/token.go b/server/token.go
index f3aa012e..d73403eb 100644
--- a/server/token.go
+++ b/server/token.go
@@ -24,10 +24,6 @@ THE SOFTWARE.
 
 package server
 
-import (
-	"math/rand"
-)
-
 const (
 	// SYMBOLS characters used for short-urls
 	SYMBOLS = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
@@ -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
 	}
 
-- 
GitLab