mirror of
https://github.com/dutchcoders/transfer.sh.git
synced 2025-01-12 20:00:17 +01:00
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
This commit is contained in:
parent
7f043ca543
commit
089ff324e1
4 changed files with 21 additions and 18 deletions
24
.github/workflows/test.yml
vendored
24
.github/workflows/test.yml
vendored
|
@ -13,9 +13,9 @@ jobs:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
go_version:
|
go_version:
|
||||||
- '1.18'
|
- '1.21'
|
||||||
- '1.19'
|
- '1.22'
|
||||||
- '1.20'
|
- '1.23'
|
||||||
- tip
|
- tip
|
||||||
name: Test with ${{ matrix.go_version }}
|
name: Test with ${{ matrix.go_version }}
|
||||||
steps:
|
steps:
|
||||||
|
@ -29,16 +29,20 @@ jobs:
|
||||||
- name: Install Go ${{ matrix.go_version }}
|
- name: Install Go ${{ matrix.go_version }}
|
||||||
if: ${{ matrix.go_version == 'tip' }}
|
if: ${{ matrix.go_version == 'tip' }}
|
||||||
run: |
|
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
|
go install golang.org/dl/gotip@latest
|
||||||
ls -lah gotip.tar.gz
|
`go env GOPATH`/bin/gotip download
|
||||||
mkdir -p ~/sdk/gotip
|
- name: Vet and test no tip
|
||||||
tar -C ~/sdk/gotip -xzf gotip.tar.gz
|
if: ${{ matrix.go_version != 'tip' }}
|
||||||
echo "PATH=$HOME/go/bin:$HOME/sdk/gotip/bin/:$PATH" >> $GITHUB_ENV
|
|
||||||
- name: Vet and test
|
|
||||||
run: |
|
run: |
|
||||||
go version
|
go version
|
||||||
go vet ./...
|
go vet ./...
|
||||||
go test ./...
|
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:
|
golangci:
|
||||||
name: Linting
|
name: Linting
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
@ -46,7 +50,7 @@ jobs:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- uses: actions/setup-go@master
|
- uses: actions/setup-go@master
|
||||||
with:
|
with:
|
||||||
go-version: '1.20'
|
go-version: '1.23'
|
||||||
check-latest: true
|
check-latest: true
|
||||||
- name: golangci-lint
|
- name: golangci-lint
|
||||||
uses: golangci/golangci-lint-action@v2
|
uses: golangci/golangci-lint-action@v2
|
||||||
|
|
|
@ -26,7 +26,7 @@ func (s *suiteRedirectWithForceHTTPS) SetUpTest(c *C) {
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
|
|
||||||
handler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
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)
|
s.handler = srvr.RedirectHandler(handler)
|
||||||
|
@ -83,7 +83,7 @@ func (s *suiteRedirectWithoutForceHTTPS) SetUpTest(c *C) {
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
|
|
||||||
handler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
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)
|
s.handler = srvr.RedirectHandler(handler)
|
||||||
|
|
|
@ -402,12 +402,15 @@ func New(options ...OptionFn) (*Server, error) {
|
||||||
return s, nil
|
return s, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var theRand *rand.Rand
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
var seedBytes [8]byte
|
var seedBytes [8]byte
|
||||||
if _, err := cryptoRand.Read(seedBytes[:]); err != nil {
|
if _, err := cryptoRand.Read(seedBytes[:]); err != nil {
|
||||||
panic("cannot obtain cryptographically secure seed")
|
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
|
// Run starts Server
|
||||||
|
|
|
@ -24,10 +24,6 @@ THE SOFTWARE.
|
||||||
|
|
||||||
package server
|
package server
|
||||||
|
|
||||||
import (
|
|
||||||
"math/rand"
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// SYMBOLS characters used for short-urls
|
// SYMBOLS characters used for short-urls
|
||||||
SYMBOLS = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
SYMBOLS = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||||
|
@ -37,7 +33,7 @@ const (
|
||||||
func token(length int) string {
|
func token(length int) string {
|
||||||
result := ""
|
result := ""
|
||||||
for i := 0; i < length; i++ {
|
for i := 0; i < length; i++ {
|
||||||
x := rand.Intn(len(SYMBOLS) - 1)
|
x := theRand.Intn(len(SYMBOLS) - 1)
|
||||||
result = string(SYMBOLS[x]) + result
|
result = string(SYMBOLS[x]) + result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue