Skip to content

Commit

Permalink
chore(go): update to go 1.21 (#4)
Browse files Browse the repository at this point in the history
* chore(go): update to go 1.21

* chore(ci): Go 1.21

* chore(ci): fix lint findings

* chore(ci): code format

* chore(ci): fix lint findings

* chore(ci): update nix shell
  • Loading branch information
Zenithar committed Apr 9, 2024
1 parent 16f4160 commit fb9b2a5
Show file tree
Hide file tree
Showing 14 changed files with 84 additions and 269 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pr-extra.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: 1.17
go-version: 1.21
- name: Run go list
run: go list -json -m all > go.list
- name: Nancy
Expand Down
42 changes: 21 additions & 21 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.17
go-version: 1.21
- name: Checkout code
uses: actions/checkout@v2
- name: Check go mod
Expand All @@ -31,10 +31,10 @@ jobs:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.17
go-version: 1.21
- uses: actions/checkout@v2
- name: lint
uses: golangci/golangci-lint-action@v2.4.0
uses: golangci/golangci-lint-action@v4.0.0
with:
version: latest

Expand All @@ -46,17 +46,17 @@ jobs:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.17 # test only the latest go version to speed up CI
- uses: actions/cache@v2.1.4
go-version: 1.21 # test only the latest go version to speed up CI
- uses: actions/cache@v4
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-1.17-${{ hashFiles('**/go.sum') }}
key: ${{ runner.os }}-go-1.21-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-${{ matrix.golang }}-
${{ runner.os }}-go-
- name: Setup gotestsum
uses: autero1/action-gotestsum@v1.0.0
uses: autero1/action-gotestsum@v2.0.0
with:
gotestsum_version: 1.7.0
gotestsum_version: 1.11.0
- name: Run tests
run: gotestsum --format short-verbose ./...

Expand All @@ -68,17 +68,17 @@ jobs:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.17 # test only the latest go version to speed up CI
- uses: actions/cache@v2.1.4
go-version: 1.21 # test only the latest go version to speed up CI
- uses: actions/cache@v4
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-1.17-${{ hashFiles('**/go.sum') }}
key: ${{ runner.os }}-go-1.21-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-${{ matrix.golang }}-
${{ runner.os }}-go-
- name: Setup gotestsum
uses: autero1/action-gotestsum@v1.0.0
uses: autero1/action-gotestsum@v2.0.0
with:
gotestsum_version: 1.7.0
gotestsum_version: 1.11.0
- name: Run tests
run: gotestsum --format short-verbose ./...

Expand All @@ -90,16 +90,16 @@ jobs:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.17 # test only the latest go version to speed up CI
- uses: actions/cache@v2.1.4
go-version: 1.21 # test only the latest go version to speed up CI
- uses: actions/cache@v4
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-1.17-${{ hashFiles('**/go.sum') }}
key: ${{ runner.os }}-go-1.21-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-${{ matrix.golang }}-
${{ runner.os }}-go-
- name: Setup gotestsum
uses: autero1/action-gotestsum@v1.0.0
uses: autero1/action-gotestsum@v2.0.0
with:
gotestsum_version: 1.7.0
gotestsum_version: 1.11.0
- name: Run tests
run: gotestsum --format short-verbose ./...
211 changes: 18 additions & 193 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,226 +1,51 @@
run:
# default concurrency is a available CPU number
concurrency: 4
# timeout for analysis, e.g. 30s, 5m, default is 1m
deadline: 20m
# exit code when at least one issue was found, default is 1
issues-exit-code: 1
# include test files or not, default is true
timeout: 5m
tests: false

skip-files:
- ".*\\.pb\\.go$"
- ".*\\.gen\\.go$"
- ".*\\_gen\\.go$"
- "mock_.*\\.go"
- ".*\\.resolvers\\.go$"

# default is true. Enables skipping of directories:
# vendor$, third_party$, testdata$, examples$, Godeps$, builtin$
skip-dirs-use-default: true

# by default isn't set. If set we pass it to "go list -mod={option}". From "go help modules":
# If invoked with -mod=readonly, the go command is disallowed from the implicit
# automatic updating of go.mod described above. Instead, it fails when any changes
# to go.mod are needed. This setting is most useful to check that go.mod does
# not need updates, such as in a continuous integration and testing system.
# If invoked with -mod=vendor, the go command assumes that the vendor
# directory holds the correct copies of dependencies and ignores
# the dependency descriptions in go.mod.
modules-download-mode: readonly

# Allow multiple parallel golangci-lint instances running.
# If false (default) - golangci-lint acquires file lock on start.
allow-parallel-runners: false

# output configuration options
output:
# colored-line-number|line-number|json|tab|checkstyle|code-climate|junit-xml|github-actions
# default is "colored-line-number"
format: colored-line-number

# print lines of code with issue, default is true
print-issued-lines: true

# print linter name in the end of issue text, default is true
print-linter-name: true

# make issues output unique by line, default is true
uniq-by-line: true

# add a prefix to the output file references; default is no prefix
path-prefix: ""

# sorts results by: filepath, line and column
sort-results: false
issues:
exclude-files:
- "testing.go"
- ".*\\.pb\\.go"
- ".*\\.gen\\.go"

linters-settings:
dogsled:
# checks assignments with too many blank identifiers; default is 2
max-blank-identifiers: 2
dupl:
# tokens count to trigger issue, 150 by default
threshold: 150
errcheck:
# report about not checking of errors in type assertions: `a := b.(MyStruct)`;
# default is false: such cases aren't reported by default.
check-type-assertions: false

# report about assignment of errors to blank identifier: `num, _ := strconv.Atoi(numStr)`;
# default is false: such cases aren't reported by default.
check-blank: false

# [deprecated] comma-separated list of pairs of the form pkg:regex
# the regex is used to ignore names within pkg. (default "fmt:.*").
# see https://github.com/kisielk/errcheck#the-deprecated-method for details
ignore: fmt:.*,io/ioutil:^Read.*
exhaustive:
# check switch statements in generated files also
check-generated: false
# indicates that switch statements are to be considered exhaustive if a
# 'default' case is present, even if all enum members aren't listed in the
# switch
default-signifies-exhaustive: false
govet:
# report about shadowed variables
check-shadowing: true
goimports:
local: "zntr.io"
golint:
min-confidence: 0.8
gofmt:
simplify: true
gocyclo:
min-complexity: 15
goconst:
min-len: 5
min-occurrences: 4
misspell:
locale: US
lll:
line-length: 140
tab-width: 1
gci:
# put imports beginning with prefix after 3rd-party packages;
# only support one prefix
# if not set, use goimports.local-prefixes
local-prefixes: zntr.io/solid
gocognit:
# minimal code complexity to report, 30 by default (but we recommend 10-20)
min-complexity: 20
goconst:
# minimal length of string constant, 3 by default
min-len: 3
# minimal occurrences count to trigger, 3 by default
min-occurrences: 3
nestif:
# minimal complexity of if statements to report, 5 by default
min-complexity: 4
gomnd:
settings:
mnd:
# don't include the "operation" and "assign"
checks: ["argument","case","condition","return"]
unused:
# treat code as a program (not a library) and report unused exported identifiers; default is false.
# XXX: if you enable this setting, unused will report a lot of false-positives in text editors:
# if it's called for subdir of a project it can't find funcs usages. All text editor integrations
# with golangci-lint call it on a directory with the changed file.
check-exported: false
unparam:
# call graph construction algorithm (cha, rta). In general, use cha for libraries,
# and rta for programs with main packages. Default is cha.
algo: cha

# Inspect exported functions, default is false. Set to true if no external program/library imports your code.
# XXX: if you enable this setting, unparam will report a lot of false-positives in text editors:
# if it's called for subdir of a project it can't find external interfaces. All text editor integrations
# with golangci-lint call it on a directory with the changed file.
check-exported: false
nakedret:
# make an issue if func has more lines of code than this setting and it has naked returns; default is 30
max-func-lines: 30
prealloc:
# Report preallocation suggestions only on simple loops that have no returns/breaks/continues/gotos in them.
# True by default.
simple: true
range-loops: true # Report preallocation suggestions on range loops, true by default
for-loops: false # Report preallocation suggestions on for loops, false by default
funlen:
lines: 100
statements: 50
gomodguard:
blocked:
modules:
- github.com/BurntSushi/toml:
recommandations:
- github.com/pelletier/go-toml
goheader:
template: |-
Licensed to SolID under one or more contributor
license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright
ownership. SolID licenses this file to you under
the Apache License, Version 2.0 (the "License"); you may
not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
gocritic:
# Enable multiple checks by tags, run `GL_DEBUG=gocritic golangci-lint run` to see all tags and checks.
# Empty list by default. See https://github.com/go-critic/go-critic#usage -> section "Tags".
enabled-tags:
- diagnostic
- performance
- style
- opinionated
- experimental

linters:
disable-all: true
enable:
- asciicheck
- bodyclose
- deadcode
- depguard
- dogsled
# - dupl
- errcheck
- errorlint
- exportloopref
- exhaustive
# - forbidigo
- funlen
# - gochecknoinits
- exportloopref
- goconst
- gocritic
- gocyclo
- godot
- gofmt
- goheader
- gofumpt
- goimports
# - golint
# - gomnd
- goprintffuncname
- gomodguard
- gosec
- gosimple
- govet
- ineffassign
# - lll
- misspell
- nakedret
- noctx
- nolintlint
- rowserrcheck
- revive
- prealloc
- exportloopref
- staticcheck
- structcheck
- unused
- stylecheck
- typecheck
- unconvert
- unparam
- unused
- varcheck
- whitespace
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ More examples - [here](example_test.go)

## Benchmarks

> Go version 1.19.5 / Mac M1
> Go version 1.21 / Mac M1
### V3

Expand All @@ -56,12 +56,12 @@ More examples - [here](example_test.go)
goos: darwin
goarch: arm64
pkg: zntr.io/paseto/v3
Benchmark_Paseto_Encrypt-10 74833 14775 ns/op 8274 B/op 59 allocs/op
Benchmark_Paseto_Decrypt-10 84738 14189 ns/op 8050 B/op 59 allocs/op
Benchmark_Paseto_Sign-10 7467 157376 ns/op 9059 B/op 86 allocs/op
Benchmark_Paseto_Verify-10 1980 604653 ns/op 3754 B/op 52 allocs/op
Benchmark_Paseto_Encrypt-10 200414 6050 ns/op 8274 B/op 59 allocs/op
Benchmark_Paseto_Decrypt-10 214208 5558 ns/op 8050 B/op 59 allocs/op
Benchmark_Paseto_Sign-10 9921 117440 ns/op 9060 B/op 86 allocs/op
Benchmark_Paseto_Verify-10 2373 504017 ns/op 2504 B/op 36 allocs/op
PASS
ok zntr.io/paseto/v3 5.373s
ok zntr.io/paseto/v3 6.169s
```

### V4
Expand All @@ -71,12 +71,12 @@ ok zntr.io/paseto/v3 5.373s
goos: darwin
goarch: arm64
pkg: zntr.io/paseto/v4
Benchmark_Paseto_Encrypt-10 461580 2580 ns/op 2288 B/op 12 allocs/op
Benchmark_Paseto_Decrypt-10 554426 2139 ns/op 2064 B/op 12 allocs/op
Benchmark_Paseto_Sign-10 47422 24875 ns/op 928 B/op 4 allocs/op
Benchmark_Paseto_Verify-10 22990 52357 ns/op 704 B/op 4 allocs/op
Benchmark_Paseto_Encrypt-10 411024 2532 ns/op 2288 B/op 12 allocs/op
Benchmark_Paseto_Decrypt-10 567030 2092 ns/op 2064 B/op 12 allocs/op
Benchmark_Paseto_Sign-10 51487 23268 ns/op 928 B/op 4 allocs/op
Benchmark_Paseto_Verify-10 23076 51794 ns/op 704 B/op 4 allocs/op
PASS
ok zntr.io/paseto/v4 6.660s
ok zntr.io/paseto/v4 5.825s
```

## License
Expand Down
Loading

0 comments on commit fb9b2a5

Please sign in to comment.