File tree Expand file tree Collapse file tree 4 files changed +21
-18
lines changed Expand file tree Collapse file tree 4 files changed +21
-18
lines changed Original file line number Diff line number Diff line change 1313 fail-fast : false
1414 matrix :
1515 go_version :
16- - ' 1.18 '
17- - ' 1.19 '
18- - ' 1.20 '
16+ - ' 1.21 '
17+ - ' 1.22 '
18+ - ' 1.23 '
1919 - tip
2020 name : Test with ${{ matrix.go_version }}
2121 steps :
@@ -29,24 +29,28 @@ jobs:
2929 - name : Install Go ${{ matrix.go_version }}
3030 if : ${{ matrix.go_version == 'tip' }}
3131 run : |
32- 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
33- ls -lah gotip.tar.gz
34- mkdir -p ~/sdk/gotip
35- tar -C ~/sdk/gotip -xzf gotip.tar.gz
36- echo "PATH=$HOME/go/bin:$HOME/sdk/gotip/bin/:$PATH" >> $GITHUB_ENV
37- - name : Vet and test
32+ go install golang.org/dl/gotip@latest
33+ `go env GOPATH`/bin/gotip download
34+ - name : Vet and test no tip
35+ if : ${{ matrix.go_version != 'tip' }}
3836 run : |
3937 go version
4038 go vet ./...
4139 go test ./...
40+ - name : Vet and test gotip
41+ if : ${{ matrix.go_version == 'tip' }}
42+ run : |
43+ `go env GOPATH`/bin/gotip version
44+ `go env GOPATH`/bin/gotip vet ./...
45+ `go env GOPATH`/bin/gotip test ./...
4246 golangci :
4347 name : Linting
4448 runs-on : ubuntu-latest
4549 steps :
4650 - uses : actions/checkout@v2
4751 - uses : actions/setup-go@master
4852 with :
49- go-version : ' 1.20 '
53+ go-version : ' 1.23 '
5054 check-latest : true
5155 - name : golangci-lint
5256 uses : golangci/golangci-lint-action@v2
Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ func (s *suiteRedirectWithForceHTTPS) SetUpTest(c *C) {
2626 c .Assert (err , IsNil )
2727
2828 handler := http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {
29- fmt .Fprintln (w , "Hello, client" )
29+ _ , _ = fmt .Fprintln (w , "Hello, client" )
3030 })
3131
3232 s .handler = srvr .RedirectHandler (handler )
@@ -83,7 +83,7 @@ func (s *suiteRedirectWithoutForceHTTPS) SetUpTest(c *C) {
8383 c .Assert (err , IsNil )
8484
8585 handler := http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {
86- fmt .Fprintln (w , "Hello, client" )
86+ _ , _ = fmt .Fprintln (w , "Hello, client" )
8787 })
8888
8989 s .handler = srvr .RedirectHandler (handler )
Original file line number Diff line number Diff line change @@ -402,12 +402,15 @@ func New(options ...OptionFn) (*Server, error) {
402402 return s , nil
403403}
404404
405+ var theRand * rand.Rand
406+
405407func init () {
406408 var seedBytes [8 ]byte
407409 if _ , err := cryptoRand .Read (seedBytes [:]); err != nil {
408410 panic ("cannot obtain cryptographically secure seed" )
409411 }
410- rand .Seed (int64 (binary .LittleEndian .Uint64 (seedBytes [:])))
412+
413+ theRand = rand .New (rand .NewSource (int64 (binary .LittleEndian .Uint64 (seedBytes [:]))))
411414}
412415
413416// Run starts Server
Original file line number Diff line number Diff line change @@ -24,10 +24,6 @@ THE SOFTWARE.
2424
2525package server
2626
27- import (
28- "math/rand"
29- )
30-
3127const (
3228 // SYMBOLS characters used for short-urls
3329 SYMBOLS = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
@@ -37,7 +33,7 @@ const (
3733func token (length int ) string {
3834 result := ""
3935 for i := 0 ; i < length ; i ++ {
40- x := rand .Intn (len (SYMBOLS ) - 1 )
36+ x := theRand .Intn (len (SYMBOLS ) - 1 )
4137 result = string (SYMBOLS [x ]) + result
4238 }
4339
You can’t perform that action at this time.
0 commit comments