8000
Skip to content

Latest commit

 

History

11 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-generic

Note

This project is under development. Breaking changes are to be expected.

Go Reference Go Report Card

This repository contains a collection of Go utility functions and types built with Go's generics.

Example usage

package main

import (
	"fmt"

	"github.com/NublyBR/go-generic"
)

func main() {
	ints := []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20}

	// Filter

	evens := generic.Filter(func(i int) bool {
		return i%2 == 0
	}, ints...)

	fmt.Println(evens) // [2 4 6 8 10 12 14 16 18 20]

	// Map

	mult := generic.Map(func(i int) int {
		return i * 2
	}, ints...)

	fmt.Println(mult) // [2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40]
}

About

Go utility functions and types built with generics.

Topics

Resources

Stars

6 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages

0