Skip to content

Conversation

@andrewkroh
Copy link
Member

@andrewkroh andrewkroh commented Jul 9, 2025

This commit addresses a large number of golangci-lint warnings across the codebase.
The fixes span multiple categories of linters.

  • Error Handling: Ensured that all error return values are checked, particularly from io.Copy and flag.Value.Set.
  • Formatting: Corrected formatting issues with gofumpt.
  • Vet and staticcheck:
    • Resolved a potential context leak in the GCS output by ensuring the cancel function is always called.
    • Replaced deprecated io/ioutil with io and os packages.
    • Replaced deprecated zap.OnFatal with zap.WithFatalHook.
    • Fixed an issue in TCP and TLS outputs where the write buffer was being modified, which is unsafe. A new buffer is now used.
    • Simplified various struct field selectors and boolean expressions.
  • Revive Linter:
    • Added comments to all exported functions, types, and methods to improve documentation.
    • Replace unused function parameters with blank identifier (_).
    • Changed function signatures to place context.Context as the first argument.
  • Code Organization:
    • Added package-level comments to all packages.
    • Renamed the internal/output/tls and internal/output/udp packages to match their dir names.
    • Added go-licenser and golangci-lint as go.mod tool dependencies. Removed tools.go.

The only remaining linter warning is for the TODO in the udp output.

@andrewkroh andrewkroh force-pushed the fix/linter-warnings branch 5 times, most recently from 8523016 to ba94778 Compare July 15, 2025 18:08
@andrewkroh andrewkroh marked this pull request as ready for review July 15, 2025 18:12
@andrewkroh andrewkroh added the Team:Security-Service Integrations Team:Security-Service Integrations label Aug 19, 2025
I think this reduces clarity when there are multiple embedded structs.
Replace tools.go with go mod tool directives.

go get -tool github.com/golangci/golangci-lint/v2/cmd/golangci-lint
go get -tool github.com/elastic/go-licenser
go mod tidy
Rename GcsOptions to GCSOptions.
Fixed an issue in TCP and TLS outputs where the write buffer was being modified, which is unsafe. A new buffer is now used.
Resolved a potential context leak in the GCS output by ensuring the cancel function is always called.
@elasticmachine
Copy link

💚 Build Succeeded

History


tool (
github.com/elastic/go-licenser
github.com/golangci/golangci-lint/v2/cmd/golangci-lint
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking back at this months later, I'm less satisfied with the go get -tool changes. If others were consuming this project as a library I would be much less inclined to use this.

@andrewkroh andrewkroh requested a review from a team November 7, 2025 21:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Team:Security-Service Integrations Team:Security-Service Integrations

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants