fatal

package module
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 12, 2024 License: MIT Imports: 2 Imported by: 1

README

fatal

fatal by LitFill. library for fatal assignment or logging (error management)

Example

Log(http.ServeAndListen(port),
    "Can not serve and listen",
    "port", port
)

file := Assign(os.Create("log.txt"),
    "Can not create file",
    "file", "log.txt"
)

Documentation

Overview

fatal, LitFill <marrazzy54 at email dot com> library for fatal assignment or logging (error management)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Assign

func Assign[T any](val T, err error, msg string, log ...any) T

Assign wraps function call returning a `val` and error to log it if error != nil using `log/slog` so it has `msg` and `log`. example:

file := Assign(os.Create("log.txt"),
    "Can not create file",
    "file", "log.txt"
)

func Log

func Log(err error, msg string, log ...any)

Log wraps function call returning error to log it using `log/slog` so it has `msg` and `log`. example:

Log(http.ServeAndListen(port),
    "Can not serve and listen",
    "port", port
)

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳