Skip to content

Latest commit

 

History

History
60 lines (37 loc) · 1.84 KB

README.md

File metadata and controls

60 lines (37 loc) · 1.84 KB

itkit

Go Reference License: APACHE-2.0 Go Report Card codecov

Short, dead simple and concise generic iterator interface. With a few extras similar to what python has to offer.

📦 Installation

$ go get -u github.com/0x5a17ed/itkit@latest

🤔 Usage

package main

import (
	"fmt"

	"github.com/0x5a17ed/itkit/iters/sliceit"
	"github.com/0x5a17ed/itkit/itlib"
)

func main() {
	s := []int{1, 2, 3}

	// iterating using the for keyword.
	for it := sliceit.In(s); it.Next(); {
		fmt.Println(it.Value())
	}

	// iterating using a slightly more functional approach.
	itlib.Apply(sliceit.In(s), func(v int) {
		fmt.Println(v)
	})
}

🥇 Acknowledgments

The iterator interface is desgined after the stateful iterators pattern explained in the brilliant blog post from https://ewencp.org/blog/golang-iterators/index.html. Most functions to manipulate iterators draw inspiration from different sources such as Python and github.com/samber/lo.

⚖️ License

itkit is licensed under the Apache License, Version 2.0.

FOSSA Status

☝️ Is it any good?

yes.