Releases: TouchBistro/goutils
v0.5.0
New packages:
logutil
: The new logutil
package provides utilities that extend the functionality of the log/slog
package.
Minor Changes:
color
:
- Added the
Colorer
type which can be used to disable colours in a local context without affecting the global functions. - Added
IsNoColorEnvSet()
to see ifNO_COLOR
is set.
Breaking Changes:
progress
:
- The
Logger
interface has been updated to work withlog/slog
andlogutil
.Logger.WithFields
has been replaced withLogger.WithAttrs
and theFields
type is gone. TheDebug
/Info
/Warn
/Error
methods require the message as the first argument, subsequent arguments are expected to be attributes that will be added to the log. PlainTracker
has been removed. See the changes to thespinner
package for how to achieve the same functionality.
spinner
:
Tracker
has been removed. InsteadNewTracker()
can be used to create aprogress.Tracker
with the given options. TheDisableSpinner
option can be used to achieve the same functionality thatprogress.PlainTracker
previously provided.
v0.4.0
New packages:
async
: The new async
package provides functionality for working with async operations. It provides the Group
type which can be used to execute a list of related operations in parallel and collect the results.
Minor Changes:
progress
:
- Added
ContextWithTrackerUsingKey
andTrackerFromContextUsingKey
which work the same asContextWithTracker
andTrackerFromContext
but allow setting a custom context key. - Added
RunOptions.TrackerKey
andRunParallelOptions.TrackerKey
which can be used to specify the key to use to retrieve theTracker
from the context. RunParallel/RunParallelT
now return results in the same order that they were run. These semantics are documented in the godoc and are part of the API contract now.
Breaking Changes:
command
:
Command.Exec
andExec
now require acontext.Context
as the first parameter. This context is used to kill the command process if the context becomes done before the process completes on its own.
progress
:
Run/RunT
andRunParallel/RunParallelT
no longer return immediately if the context becomes done but rather wait for the running functions to complete. This behaviour was deemed undesirable as it meant that operations were still running concurrently afterRun/RunParallel
returned which might be unexpected. The semantics now are that whenRun/RunParallel
return, there are no concurrent operations running. It is up to callers to ensure that their functions use the context properly to handle timeouts/cancellations.RunParallel/RunParallelT
no longer return immediately ifCancelOnError
is true but wait for the running functions to complete for the same reasons as describe in the previous point.
v0.3.2
v0.3.1
v0.3.0
New packages:
log
: The new log
package provides a simple yet powerful structured logger that can log at different levels.
The Logger type implements the progress.Logger
and progress.OutputLogger
interfaces, making it easy to use with the progress
package.
Minor Changes:
progress
:
- Added
RunOptions.Count
field to allow specifying a count for the spinner run byRun
.
Breaking Changes:
command
:
- Renamed
IsAvailable
toExists
.
fatal
:
- Redesigned
fatal
package. - The
Error
type can be used to represent a fatal error that requires the application to terminate with context. - The
Exiter
type allows exiting the application, with different options.
progress
:
SpinnerTracker
has been moved to thespinner
package. Usespinner.Tracker
instead now.RunParallelOptions.Concurrency
is now typeint
instead ofuint
.DefaultConcurrency
now returns anint
instead of auint
.
v0.2.0
New packages:
errors
: The new errors
package provides functionality for creating and working with errors.
- The
Error
type allows for created detailed errors. These errors can be wrapped to create detailed error chains. - The
List
type allows for creating lists of errors. - Provides all the same functionality as the standard library
errors
package so this package can be used as a replacement.
progress
: The new progress
package provides functionality for running operations and displaying their progress.
- Provides the
Logger
,Spinner
, andTracker
types for displaying progress. - Provides the
Run
andRunParallel
functions for running operations.
text
: The new text
package provides functionality for working with text.
- The
ExpandVariables
andExpandVariablesString
functions can be used to expand variables in text.
Minor Changes:
color
:
- Added the
Black
function to create black coloured strings. - Refactored implementation to be faster.
file
:
- Added the
Untar
function to extract tar archives onto the OS filesystem.
Breaking Changes:
fatal
:
ShowStackTraces
has been renamed toPrintDetailedError
.
v0.1.0
This marks the first proper release of goutils
. We have done a major vetting and redesign of all the available APIs. This release include several breaking changes. Please note that while we now have a better of what the goutils API should be, this library is not yet stable.
Changes include:
- Completely redesigned the spinner package. New spinner with support for progress messages and logging while the spinner is running.
- Redesigned command package. The API is easier to use and is driven by functional options.
- Redesigned the files package to have clearer function names.
All APIs are now properly documented with godoc. We recommend viewing the docs for details on the new APIs.
v0.0.3
Features:
- Add
fatal.OnExit
which allows a function to be registered that will run before callingos.Exit
. This is useful sincedefer
s are not called whenos.Exit
is called. color
now supportsNO_COLOR
. If theNO_COLOR
environment variable is set, no colors will be added.color
now strips reset codes from any strings instead of assuming the input will always be good. This way strings with reset codes in it won't prevent the whole string from being colored.
BREAKING CHANGES:
fatal.ShowStackTraces
is now a function that takes a bool to set whether or not stack traces are shown. Also stack traces are not shown by default now and must be explicitly enabled.