Skip to content

Commit

Permalink
Upgraded linter, added github workflow go1.20
Browse files Browse the repository at this point in the history
  • Loading branch information
bogcon committed Jun 20, 2023
1 parent caa7573 commit 9ce0932
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
timeout-minutes: 5
strategy:
matrix:
go-version: [1.16.x, 1.17.x, 1.18.x, 1.19.x]
go-version: [1.16.x, 1.17.x, 1.18.x, 1.19.x, 1.20.x]
platform: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.platform }}

Expand Down Expand Up @@ -44,7 +44,7 @@ jobs:
run: make clean cover

- name: Upload coverage to coveralls.io
if: matrix.platform == 'ubuntu-latest' && matrix.go-version == '1.19.x'
if: matrix.platform == 'ubuntu-latest' && matrix.go-version == '1.20.x'
uses: shogo82148/actions-goveralls@v1
with:
path-to-profile: cover.out
Expand Down
1 change: 1 addition & 0 deletions .golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ linters:
- goconst
- gocritic
- godot
- lll
- misspell
- nlreturn
- noctx
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
LINTER_VERSION=v1.49.0
LINTER_VERSION=v1.53.3
LINTER=./bin/golangci-lint
ifeq ($(OS),Windows_NT)
LINTER=./bin/golangci-lint.exe
Expand Down Expand Up @@ -29,7 +29,7 @@ test: ## Run tests (with race condition detection).

.PHONY: bench
bench: ## Run benchmarks.
go test -race -run=^# -benchmem -benchtime=5s -bench=.
go test -race -benchmem -benchtime=5s -bench=.

.PHONY: cover
cover: ## Run tests with coverage. Generates "cover.out" profile and its html representation.
Expand Down
6 changes: 3 additions & 3 deletions rand.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,10 @@ const (
)

// String generates a random string of length n with letters from the alphabet.
// Alphabet is optional and defaults to AlphanumAlphabet if not provided.
// Alphabet is optional and defaults to [AlphanumAlphabet] if not provided.
func String(n int, alphabet ...string) string {
// Note: implementation details are explained here: https://stackoverflow.com/a/31832326
// See also similar impl: https://github.com/kubernetes/apimachinery/blob/v0.24.2/pkg/util/rand/rand.go#L98
// See also similar impl: https://github.com/kubernetes/apimachinery/blob/v0.27.3/pkg/util/rand/rand.go#L98
var a string
if len(alphabet) > 0 && len(alphabet[0]) > 0 {
a = alphabet[0]
Expand All @@ -99,7 +99,7 @@ func String(n int, alphabet ...string) string {
var (
alphabetIdxBits = countBits(len(a)) // represents the max no. of bits to represent an index in alphabet.
alphabetIdxMask int64 = 1<<alphabetIdxBits - 1 // 1...1b bits, of length alphabetIdxBits
alphabetIdxMax = 63 / alphabetIdxBits // no. of random letters/their indexes we can extract from a single int63
alphabetIdxMax = 63 / alphabetIdxBits // no. of random letters/their indexes we can extract from an int63
b = make([]byte, n)
)

Expand Down

0 comments on commit 9ce0932

Please sign in to comment.