lox

package module
v0.0.0-...-9ca2bf9 Latest Latest
Warning

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

Go to latest
Published: May 25, 2022 License: Apache-2.0 Imports: 0 Imported by: 2

README ¶

lox 🥯

Extends samber/lo with error handling and other useful utilities.

🚀 Install

go get github.com/otterize/lox

💡 Usage

package main

import (
	"fmt"
	"github.com/otterize/lox"
	"strings"
)

func main() {
	names, err := lox.MapErr([]string{"Otter", "Other", "Utter"}, func(s string, i int) (string, error) {
		if s == "" {
			return "", fmt.Errorf("empty name")
		}
		return s, nil
	})

	if err != nil {
		panic(err)
	}

	fmt.Printf("Names: %s", strings.Join(names, ","))
}

👤 Authors

Documentation ¶

Index ¶

Constants ¶

This section is empty.

Variables ¶

This section is empty.

Functions ¶

func MapErr ¶

func MapErr[T any, R any](collection []T, iteratee func(T, int) (R, error)) ([]R, error)

MapErr is similar to lo.Map, but handles error in iteratee function

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