Skip to content
/ itkit Public
forked from 0x5a17ed/itkit

Dead simple generic iterator interface

License

Notifications You must be signed in to change notification settings

fossabot/itkit

 
 

Repository files navigation

itkit

Go Reference License: APACHE-2.0 Go Report Card FOSSA Status

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.

☝️ Is it any good?

yes.

License

FOSSA Status

About

Dead simple generic iterator interface

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 100.0%