Per the [Go Release Policy][1], upstream supports
only the two most recent major releases of Go.
For example, with Go 1.21 available, only 1.21 and 1.20 are supported.
Many projects adopt a similar support policy
to strike a balance between new features and backwards support.
[1]: https://go.dev/doc/devel/release#policy
If the project has the same policy,
it makes sense to test against both versions of Go.
This change adds a test matrix to CI,
testing against both Go 1.20 and 1.21,
on both Windows and Linux.
The golangci-lint being used was quite dated.
This change upgrades to the latest version.
Adds and updates exclusions based on new failures.
Note on revive:
I've included an opt-out for unused parameters for revive
because turning `newThing(required bool)` to `newThing(_ bool)`
is a loss of useful information.
The changes to the Go files are to fix the following issues:
```
camelcase.go:16: File is not `gofmt`-ed with `-s` (gofmt)
config_test.go:50:18: directive `//nolint: gosec` is unused for linter "gosec" (nolintlint)
defaults_test.go:28:25: G601: Implicit memory aliasing in for loop. (gosec)
doc.go:5: File is not `gofmt`-ed with `-s` (gofmt)
kong.go:446:18: directive `//nolint: gosec` is unused for linter "gosec" (nolintlint)
kong_test.go:503:20: G601: Implicit memory aliasing in for loop. (gosec)
model.go:493:10: composites: reflect.ValueError struct literal uses unkeyed fields (govet)
scanner.go:112: File is not `gofmt`-ed with `-s` (gofmt)
```
And to address broken nolint directives reported as follows by
golangci-lint.
```
[.. skipped .. ]
tag.go:65:1: directive `// nolint:gocyclo` should be written without leading space as `//nolint:gocyclo` (nolintlint)
tag.go:206:51: directive `// nolint: gocyclo` should be written without leading space as `//nolint: gocyclo` (nolintlint)
util_test.go:23:43: directive `// nolint: errcheck` should be written without leading space as `//nolint: errcheck` (nolintlint)
util_test.go:51:22: directive `// nolint: errcheck` should be written without leading space as `//nolint: errcheck` (nolintlint)
```
* ci: Test on Windows too
Adds a Windows test run to CI.
Go setup relies on GHA for this
because Hermit doesn't yet support Windows.
* fix(mapper_windows_test): assert.NotNil => assert.True
assert.NotNil does not exist.
* filecontent mapper: Handle error from directory
If we couldn't read because the source is a directory,
override the original error message.
* fix(test): Handle platform-specific "file not found" messages
The former allows arbitrary structs to be embedded in the root of the
CLI, with optional tags.
The latter allows an arbitrary function to be called using Kong's
binding functionality.