diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6096200..0ce7241 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,14 +1,14 @@ -name: Test +name: 'Test' on: push: branches: - - main + - 'main' tags: - - '*' + - '*' pull_request: branches: - - main + - 'main' jobs: # unit runs the unit tests @@ -16,38 +16,28 @@ jobs: strategy: fail-fast: false matrix: - go: - - '1.14' - - '1.15' - - '1.16' - - '1.17' os: - - 'macos-latest' - - 'ubuntu-latest' - - 'windows-latest' + - 'macos-latest' + - 'ubuntu-latest' + - 'windows-latest' - runs-on: ${{ matrix.os }} + runs-on: '${{ matrix.os }}' steps: - - uses: actions/checkout@v2 + - uses: 'actions/checkout@v4' - - uses: actions/setup-go@v2 + - uses: 'actions/setup-go@v5' with: - go-version: ${{ matrix.go }} - - - uses: actions/cache@v2 - with: - path: ~/go/pkg/mod - key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} - restore-keys: | - ${{ runner.os }}-go- + go-version-file: 'go.mod' - name: Lint - run: make fmtcheck staticcheck spellcheck - if: ${{ matrix.os == 'ubuntu-latest' && matrix.go == '1.16' }} + if: ${{ matrix.os == 'ubuntu-latest' }} + run: |- + make fmtcheck staticcheck spellcheck - name: Test - run: make test + run: |- + make test-acc # build runs go build on the target platforms to ensure the runtime links are # correct. @@ -56,34 +46,28 @@ jobs: fail-fast: false matrix: goos: - - 'darwin' - - 'freebsd' - - 'linux' - - 'netbsd' - - 'openbsd' - - 'solaris' - - 'windows' + - 'darwin' + - 'freebsd' + - 'linux' + - 'netbsd' + - 'openbsd' + - 'solaris' + - 'windows' goarch: - - 'amd64' + - 'amd64' runs-on: 'ubuntu-latest' steps: - - uses: actions/checkout@v2 - - - uses: actions/setup-go@v2 - with: - go-version: '1.16' + - uses: 'actions/checkout@v4' - - uses: actions/cache@v2 + - uses: 'actions/setup-go@v5' with: - path: ~/go/pkg/mod - key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} - restore-keys: | - ${{ runner.os }}-go- + go-version-file: 'go.mod' - name: Build env: GOOS: ${{ matrix.goos }} GOARCH: ${{ matrix.goarch }} - run: go build ./... + run: |- + go build -a ./... diff --git a/Makefile b/Makefile index f8073e2..193be71 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,3 @@ -VETTERS = "asmdecl,assign,atomic,bools,buildtag,cgocall,composites,copylocks,errorsas,httpresponse,loopclosure,lostcancel,nilfunc,printf,shift,stdmethods,structtag,tests,unmarshal,unreachable,unsafeptr,unusedresult" GOFMT_FILES = $(shell go list -f '{{.Dir}}' ./...) benchmarks: @@ -6,7 +5,7 @@ benchmarks: .PHONY: benchmarks fmtcheck: - @command -v goimports > /dev/null 2>&1 || (cd tools/ && go get golang.org/x/tools/cmd/goimports) + @command -v goimports > /dev/null 2>&1 || (cd tools/ && go install golang.org/x/tools/cmd/goimports@latest) @CHANGES="$$(goimports -d $(GOFMT_FILES))"; \ if [ -n "$${CHANGES}" ]; then \ echo "Unformatted (run goimports -w .):\n\n$${CHANGES}\n\n"; \ @@ -21,29 +20,31 @@ fmtcheck: .PHONY: fmtcheck spellcheck: - @command -v misspell > /dev/null 2>&1 || (cd tools/ && go get github.com/client9/misspell/cmd/misspell) + @command -v misspell > /dev/null 2>&1 || (cd tools/ && go install github.com/client9/misspell/cmd/misspell@latest) @misspell -locale="US" -error -source="text" **/* .PHONY: spellcheck staticcheck: - @command -v staticcheck > /dev/null 2>&1 || (cd tools/ && go get honnef.co/go/tools/cmd/staticcheck) + @command -v staticcheck > /dev/null 2>&1 || (cd tools/ && go install honnef.co/go/tools/cmd/staticcheck@latest) @staticcheck -checks="all" -tests $(GOFMT_FILES) .PHONY: staticcheck test: @go test \ -count=1 \ + -shuffle=on \ -short \ -timeout=5m \ - -vet="${VETTERS}" \ + -vet=all \ ./... .PHONY: test test-acc: @go test \ -count=1 \ + -shuffle=on \ -race \ -timeout=10m \ - -vet="${VETTERS}" \ + -vet=all \ ./... .PHONY: test-acc diff --git a/README.md b/README.md index e7d4055..cf23bed 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Go Rate Limiter -[![GoDoc](https://img.shields.io/badge/go-documentation-blue.svg?style=flat-square)](https://pkg.go.dev/mod/github.com/sethvargo/go-limiter) -[![GitHub Actions](https://img.shields.io/github/workflow/status/sethvargo/go-limiter/Test?style=flat-square)](https://github.com/sethvargo/go-limiter/actions?query=workflow%3ATest) +[![GoDoc](https://img.shields.io/badge/go-documentation-blue.svg?style=flat-square)](https://pkg.go.dev/github.com/sethvargo/go-limiter) +[![GitHub Actions](https://img.shields.io/github/actions/workflow/status/sethvargo/go-limiter/test.yml?style=flat-square)](https://github.com/sethvargo/go-limiter/actions/workflows/test.yml) This package provides a rate limiter in Go (Golang), suitable for use in HTTP diff --git a/go.mod b/go.mod index 925cd4f..efc0b4b 100644 --- a/go.mod +++ b/go.mod @@ -1,3 +1,5 @@ module github.com/sethvargo/go-limiter -go 1.14 +go 1.22 + +toolchain go1.22.1 diff --git a/internal/fasttime/fasttime.go b/internal/fasttime/fasttime.go index 39cea2d..f1e96df 100644 --- a/internal/fasttime/fasttime.go +++ b/internal/fasttime/fasttime.go @@ -1,5 +1,4 @@ //go:build !windows -// +build !windows // Package fasttime gets wallclock time, but super fast. package fasttime diff --git a/internal/fasttime/fasttime_windows.go b/internal/fasttime/fasttime_windows.go index 311f80d..03c1d90 100644 --- a/internal/fasttime/fasttime_windows.go +++ b/internal/fasttime/fasttime_windows.go @@ -1,4 +1,4 @@ -// +build windows +//go:build windows package fasttime