fn

package
v0.12.2 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2022 License: MIT Imports: 2 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HasNoError added in v0.9.0

func HasNoError(action func()) func() error

func HoldContext added in v0.9.0

func HoldContext(ctx context.Context, action func(context.Context) error) func() error

func Must

func Must(actions ...func() error)

Must execs the actions step by step and raises a panic with error and its stack trace if something went wrong.

func Configure(cmd *cobra.Command) {
	fn.Must(
		func() error { return cmd.MarkFlagRequired("file") },
		func() error { return cmd.MarkFlagRequired("format") },
	)
}

func Repeat

func Repeat(action func() error, times int) error

Repeat repeats the action the required number of times.

func FillByValue(slice []int, value int) error {
	return fn.Repeat(
		fn.HasNoError(func () { slice = append(slice, value) }),
		cap(slice) - len(slice),
	)
}

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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