fleet/orbit/pkg/go-paniclog
Jordan Montgomery c97a0e2363
Fix Windows lint issues and enable linting on Windows (#28704)
For https://github.com/fleetdm/fleet/issues/9943

This will help us avoid issues like this where the log message never
worked right:
https://github.com/fleetdm/fleet/pull/28296#discussion_r2047505191

Most of the changes are no-op type changes like removing unneeded
typecast or disabling gosec on reviewed lines of code

# Checklist for submitter

If some of the following don't apply, delete the relevant line.

<!-- Note that API documentation changes are now addressed by the
product design team. -->

- [x] Input data is properly validated, `SELECT *` is avoided, SQL
injection is prevented (using placeholders for values in statements)
- [x] Added/updated automated tests
- [x] A detailed QA plan exists on the associated ticket (if it isn't
there, work with the product group's QA engineer to add it)
- [x] Manual QA for all new/changed functionality
- For Orbit and Fleet Desktop changes:
- [x] Make sure fleetd is compatible with the latest released version of
Fleet (see [Must
rule](https://github.com/fleetdm/fleet/blob/main/docs/Contributing/fleetd-development-and-release-strategy.md)).
- [x] Orbit runs on macOS, Linux and Windows. Check if the orbit
feature/bugfix should only apply to one platform (`runtime.GOOS`).
- [x] Manual QA must be performed in the three main OSs, macOS, Windows
and Linux.
- [x] Auto-update manual QA, from released version of component to new
version (see [tools/tuf/test](../tools/tuf/test/README.md)).
2025-05-02 16:11:26 -04:00
..
example Fix Fleet Desktop bugs on Windows (#16402) 2024-01-29 18:52:55 -03:00
LICENSE Fix Fleet Desktop bugs on Windows (#16402) 2024-01-29 18:52:55 -03:00
paniclog.go Fix Fleet Desktop bugs on Windows (#16402) 2024-01-29 18:52:55 -03:00
paniclog_other.go Fix Fleet Desktop bugs on Windows (#16402) 2024-01-29 18:52:55 -03:00
paniclog_unix.go Fix Fleet Desktop bugs on Windows (#16402) 2024-01-29 18:52:55 -03:00
paniclog_windows.go Fix Windows lint issues and enable linting on Windows (#28704) 2025-05-02 16:11:26 -04:00
README.md Fix Fleet Desktop bugs on Windows (#16402) 2024-01-29 18:52:55 -03:00

This package was copied from https://github.com/virtuald/go-paniclog

go-paniclog

By default, panics in golang are sent to stderr. Unfortunately, there isn't a direct builtin global mechanism to capture/send the output of the panic to a file or really do anything with it other than to write to stderr.

One possible solution is that you can redirect stderr to a file, and that's all that this package does. Of course, once you redirect stderr to file, anything else you write to stderr will also end up in that file. v2.0 now includes a function you can use to undo the redirection if you wanted to do that for some reason.

Reference: https://stackoverflow.com/questions/34772012/capturing-panic-in-golang

Alternatives

  • panicwrap may be a better solution for many programs

Author

I can't claim any credit for this idea or the code, it is entirely taken from the rclone program by Nick Craig-Wood.

License

MIT License