build: update golangci-lint to v2.12.2 with canonical config
All checks were successful
check / check (push) Successful in 29s
check / check (pull_request) Successful in 32s

Add the canonical .golangci.yml (v2 schema, all linters enabled with a
small documented disable list) and pin the Dockerfile lint stage to
golangci/golangci-lint:v2.12.2 by tag and digest, replacing the old
v1.64.8 digest-only pin.

Fix all findings surfaced by the v1 to v2 jump without changing any
exported signatures or behavior:

- add package and exported-symbol doc comments (revive)
- rename unused handler parameters to underscore (revive)
- check or explicitly discard error returns (errcheck, errchkjson)
- wrap errors with %w instead of %v (err113)
- use http.NewRequestWithContext instead of http.Post (noctx)
- replace fmt.Println with fmt.Fprintln(os.Stdout, ...) (forbidigo)
- name magic numbers as constants (mnd)
- add explicit slog.LevelDebug case (exhaustive)
- interface{} to any (modernize)
- move tests to the simplelog_test package (testpackage) and add
  t.Parallel() (paralleltest)
- move NewWebhookHandler above its methods (funcorder)
- whitespace, line-length, and blank-line fixes (wsl_v5, whitespace,
  nlreturn, lll, embeddedstructfieldcheck)
- nolint with justification for the intentional init/global design
  (gochecknoinits, gochecknoglobals) and interface-returning
  constructor (ireturn)
This commit is contained in:
2026-08-07 17:10:03 +00:00
parent 6cb690bfb7
commit 403ba4c42e
13 changed files with 204 additions and 48 deletions

View File

@@ -8,26 +8,38 @@ import (
"os"
)
// JSONHandler writes each log record to stdout as a JSON document.
type JSONHandler struct{}
// NewJSONHandler returns a new JSONHandler.
func NewJSONHandler() *JSONHandler {
return &JSONHandler{}
}
func (j *JSONHandler) Handle(ctx context.Context, record slog.Record) error {
jsonData, _ := json.Marshal(record)
fmt.Fprintln(os.Stdout, string(jsonData))
// Handle marshals the record to JSON and writes it to stdout.
func (j *JSONHandler) Handle(_ context.Context, record slog.Record) error {
jsonData, err := json.Marshal(record)
if err != nil {
return err
}
_, _ = fmt.Fprintln(os.Stdout, string(jsonData))
return nil
}
func (j *JSONHandler) Enabled(ctx context.Context, level slog.Level) bool {
// Enabled reports whether the handler processes records at the given
// level; it always returns true.
func (j *JSONHandler) Enabled(_ context.Context, _ slog.Level) bool {
return true
}
func (j *JSONHandler) WithAttrs(attrs []slog.Attr) slog.Handler {
// WithAttrs returns the handler unchanged; attributes are not rendered.
func (j *JSONHandler) WithAttrs(_ []slog.Attr) slog.Handler {
return j
}
func (j *JSONHandler) WithGroup(name string) slog.Handler {
// WithGroup returns the handler unchanged; groups are not rendered.
func (j *JSONHandler) WithGroup(_ string) slog.Handler {
return j
}