Documentation
¶
Index ¶
- func BroadcastIP(network *net.IPNet) (*net.IP, error)
- func GenerateHashSHA512(data io.ReadCloser) []byte
- func PanicOnError(e error)
- func PanicOnError2[T any](v T, e error) T
- func SignalHandler(applicationMain func(), shutdownHandler func(), signals ...os.Signal)
- func StripError[T any](v T, e error) T
- type Optional
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BroadcastIP ¶
BroadcastIP returns the IPv4 broadcast address for the given network. An error is returned when the supplied IPNet is not IPv4 compatible.
func GenerateHashSHA512 ¶
func GenerateHashSHA512(data io.ReadCloser) []byte
GenerateHashSHA512 streams the provided reader through SHA-512 and returns the resulting digest. Callers are responsible for closing the reader.
func PanicOnError ¶
func PanicOnError(e error)
PanicOnError aborts execution when the supplied error is non-nil. It centralizes defensive checks so call sites stay readable.
func PanicOnError2 ¶
PanicOnError2 returns the provided value while panicking if the error is non-nil. It is useful when callers want the familiar value, err signature but still treat non-nil errors as fatal.
func SignalHandler ¶
SignalHandler runs applicationMain asynchronously and blocks until one of the provided OS signals arrives, then invokes shutdownHandler for cleanup.
Types ¶
type Optional ¶
type Optional[T any] struct { // contains filtered or unexported fields }
Optional wraps a value that may or may not be specified. Remember to pass pointer types when zero values would be ambiguous.
func NewOptional ¶
NewOptional produces a new Optional with an initial value and unspecified state. The value is returned until Specify is called.
func (*Optional[T]) Get ¶
func (opt *Optional[T]) Get() T
Get returns the stored value regardless of specification state.
func (*Optional[T]) Specified ¶
Specified reports whether a caller previously invoked Specify.
Source Files
¶
- ErrorHandling.go
- Hashing.go
- Net.go
- OSSignals.go
- Optional.go