Switch to slog
This pull request includes several updates and improvements across multiple files, focusing on upgrading dependencies, enhancing logging, and refactoring code for better readability and maintainability. Below are the most important changes grouped by theme:
Dependency Upgrades:
- Updated the
actions/setup-goaction to version 5 and set the Go version tostablein.github/workflows/build.ymland.github/workflows/release.yml. [1] [2] - Updated the
goreleaser/goreleaser-actionto version 6 in.github/workflows/release.yml.
Configuration and Build:
- Added a new configuration file
.golangci.ymlto enable specific linters and set exclusion rules for test files. - Updated the
Makefileto use the-trimpathflag in thebuildtarget and upgraded the Go version indockertestanddockerintegtargets. [1] [2]
Logging Enhancements:
- Replaced the standard
logpackage withlog/slogfor structured logging incmd/process-exporter/main.goandcollector/process_collector.go. [1] [2] - Updated various logging statements to use the new logger and improved error handling in
cmd/process-exporter/main.go. [1] [2]
Code Refactoring:
- Refactored flag handling in
cmd/process-exporter/main.goto usekingpinfor better command-line argument parsing. - Replaced deprecated functions
ioutil.TempFileandioutil.ReadFilewithos.CreateTempandos.ReadFilerespectively incmd/load-generator/main.goandconfig/config.go. [1] [2]
Miscellaneous:
- Added build constraint
//go:build linuxtocmd/load-generator/main.gofor specifying the target operating system. - Simplified variable declarations and error handling in
cmd/integration-tester/main.go. [1] [2]
These changes collectively aim to modernize the codebase, improve logging, and ensure compatibility with the latest tools and dependencies.
Thanks @lucacome, this is a generous contribution. I'm sorry I didn't get around to looking at it until now. Part of the issue is that it's a bunch of unrelated changes. Would you mind splitting it into at least two PRs - one for the dependency updates/configuration/build stuff, and one for the Go changes? Ideally I'd like to see the kingpin change in its own PR too, as that's the one I'm least certain I want.