must

package
v0.37.0 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2023 License: Apache-2.0 Imports: 7 Imported by: 51

Documentation

Overview

Package must simplifies writing advent-of-code scripts by providing methods that cause fatal errors instead of returning them.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Atoi

func Atoi(s string) int

Atoi converts a string to an int.

func Atoi64 added in v0.0.33

func Atoi64(s string) int64

Atoi64 converts a string to an int64.

func ParseBool

func ParseBool(str string) bool

ParseBool parses a boolean. It dies if there is an error.

func ParseComplex

func ParseComplex(s string, bitSize int) complex128

ParseComplex parses a complex number with the given bitSize. It dies if there is an error.

func ParseDuration

func ParseDuration(s string) time.Duration

ParseDuration parses a duration string. A duration string is a possibly signed sequence of decimal numbers, each with optional fraction and a unit suffix, such as "300ms", "-1.5h" or "2h45m". Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h".

func ParseFloat

func ParseFloat(s string, bitSize int) float64

ParseFloat parses a complex number with the given bitSize. It dies if there is an error.

func ParseInt

func ParseInt(s string, base, bitSize int) int

ParseInt parses an integer with the given base and bitSize. It dies if there is an error.

func ParseTime added in v0.0.6

func ParseTime(layout, value string) time.Time

ParseTime parses a formatted string and returns the time value it represents. It dies if there is an error.

func ParseTimeInLocation added in v0.0.6

func ParseTimeInLocation(layout, value string, loc *time.Location) time.Time

ParseTimeInLocation is like Parse but differs in two important ways. First, in the absence of time zone information, Parse interprets a time as UTC; ParseInLocation interprets the time as in the given location. Second, when given a zone offset or abbreviation, Parse tries to match it against the Local location; ParseInLocation uses the given location.

func ParseUint

func ParseUint(s string, base int, bitSize int) uint64

ParseUint parses an unsigned integer with the given base and bitSize. It dies if there is an error.

func ReadFile

func ReadFile(filename string) string

ReadFile reads a file as a string or causes a fatal error. It trims extra trailing whitespace from the string.

func ReadFileLines

func ReadFileLines(filename string) []string

ReadFileLines reads a file and returns a slice of lines.

func ReadImage added in v0.0.28

func ReadImage(filename string) image.Image

func ReadSplitFile added in v0.0.30

func ReadSplitFile(filename, split string) []string

ReadSplitFile reads a file and splits on the given string.

Types

This section is empty.

Jump to

Keyboard shortcuts

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