sugar

package
v3.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2024 License: MIT Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Must

func Must[T any](t T, err error) T

Must panics if err is not nil, otherwise returns t. It is useful for simplifying error handling. Example:

file, err := os.Open("file.txt")
if err != nil {
  panic(err)
}
defer file.Close()
// use file

can be simplified to:

file := sugar.Must(os.Open("file.txt")).(*os.File)
defer file.Close()
// use file

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL