Categorygithub.com/omegaup/go-base/v2
modulepackage
2.5.0
Repository: https://github.com/omegaup/go-base.git
Documentation: pkg.go.dev

# README

go-base

Documentation Go Report Card

Common Go utilities that are used across omegaUp's projects.

# Packages

No description provided by the author
No description provided by the author

# Functions

ErrorCallerStackHandler creates a handler that drops all logs that are less important than maxLvl, and also adds a stack trace to all events that are errors / critical, as well as the error values that have a stack trace.
ErrorWithCategory is similar to errors.Wrap, but instead of creating a new error as the wrapping message, a sentinel error is provided as a category.
FloatToRational returns a rational that's within 1e-6 of the floating-point value.
HasErrorCategory returns whether the provided error belongs to the provided category.
MaxBytes returns the larger of x or y.
MaxDuration returns the larger of x or y.
MinBytes returns the smaller of x or y.
MinDuration returns the smaller of x or y.
NewLRUCache returns an empty LRUCache with the provided size limit.
NewRotatingFile opens path for writing in append-only mode and listens for SIGHUP so that it can reopen the file automatically.
NopOpenedCallback is an OpenedCallback that does nothing.
ParseRational returns a rational that's within 1e-6 of the floating-point value that has been serialized as a string.
RationalDiv implements division between two rationals.
RationalToFloat returns the closest float value to the given big.Rat.
RotatingLog opens a log15.Logger, and if it will be pointed to a real file, it installs a SIGHUP handler that will atomically reopen the file and redirect all future logging operations.
StderrHandler cretes a log15.Handler that outputs to stderr (like log15.StderrHandler), but also lets the caller optionally choose to format the output in JSON instead of logfmt.
StderrLog creates a log15.Logger that outputs to stderr and prints the stack for the log call and the error stack trace if available.
UnwrapCauseFromErrorCategory finds an error with the specified category in the chain and returns its Cause().

# Constants

Gibibyte is 1024 Mebibytes.
Kibibyte is 1024 Bytes.
Mebibyte is 1024 Kibibytes.
Tebibyte is 1024 Gibibytes.

# Structs

LRUCache handles a pool of sized resources.
NoOpMetrics is an implementation of Metrics that does nothing.
A RotatingFile is an io.WriteCloser that supports reopening through SIGHUP.
A SizedEntryRef is a wrapper around a SizedEntry.

# Interfaces

Metrics is an interface that supports updating different kinds of metrics.
A SizedEntry is an entry within the LRUCache that knows its own size.

# Type aliases

A Byte is a unit of digital information.
Duration is identical to time.Duration, except it can implements the json.Marshaler interface with time.Duration.String() and time.Duration.ParseDuration().
OpenedCallback allows the caller to specify an action to be performed when the file is opened and before it is available for writing.
A SizedEntryFactory is a factory that can create a SizedEntry given its key name.