Some utility functions for generic types in Go.

GOUF - Utility Functions for generic types

Go team released Go 1.18 beta recently with support for Generics(a.k.a type parameters). This package provides much needed and frequently used utility functions for generic data types.

Supported Operations

Slices

  • All - Check if all elements in a slice satisfy a condition
  • Any - Check if any element in a slice satisfies a condition
  • Check - Check if slice can accept a given indices
  • Count - count all elements in a slice that satisfy a condition
  • Delete - Delete element at given index
  • DeleteUnordered - Delete element at given index, without preserving order(efficient than Delete)
  • DeleteFn - Delete element that satisfies a condition
  • DeletePlaces - Delete elements at given indices
  • Filter - Filter elements in a slice that satisfy a condition
  • FilterInPlace - Filter elements in a slice that satisfy a condition without allocating new slice(efficient than Filter)
  • FilterInPlaceGC - Filter elements in a slice that satisfy a condition without allocating new slice and zeroing wanted elements(efficient than Filter)
  • FindFn - Find element in a slice(for comparable types)
  • FindFn - Find element in a slice that satisfies a condition
  • Map - Map elements in a slice
  • Reduce - Reduce elements in a slice to a single value
  • Sum - Sum all elements in a slice (for numeric/string types)
  • SumFn - Sum all elements in a slice that satisfy a condition(for custom types)
  • Unique - Remove duplicate elements in a slice (for comparable types)
  • UniqueFn - Remove duplicate elements in a slice that satisfy a condition(for custom types)
  • UniqueInPlace - Remove duplicate elements in a slice without allocating new slice(efficient than Unique)
  • UniqueFnInPlace - Remove duplicate elements in a slice without allocating new slice(efficient than UniqueFn)

And a lot more(in pipeline).

Maps

TBD

Want to contribute?

see guide.

Contact

Akshay Bharambe

Feedback

This is very much important to improve this package. Do let me know if you have any feedback. Leave a if you find this helpful.

Owner
Akshay Bharambe
Software Developer 👨‍💻️ by passion | Tech Geek | Open for contributions | ❤️ Go | On a mission to spread the knowledge ☑️ | Feel free to get in touch.
Akshay Bharambe
Similar Resources

conditiond is a generic constraint and policy evaluator.

conditiond conditiond is a generic constraint and policy evaluator. This tool lets you define constraints in data and evaluate them at run time. It's

Dec 5, 2022

Generic Free List implementation to reuse memory and avoid allocations

gofl GOFL provides a Generic Free List implementation for Go. Installation This

Oct 17, 2022

Di - A (very) WIP Go 1.18+ generic dependency injection package based on type reflection

di A (very) WIP Go 1.18+ generic dependency injection package based on type refl

Apr 26, 2022

🚀 GoDI: Generic based DI in Go

🚀 GoDI: Generic based DI in Go Installation DI: go get -u github.com/MaximZayats/godi/ import "github.com/MaximZayats/godi/di" CMD: go get -u github.

Aug 14, 2022

Generic-based collection tools

go-collection go collection is a tool implemented using generic, it can help you process slice/map data quickly and easily convert between them. Note:

Dec 29, 2022

This project provides some working examples using Go and Hotwire Turbo.

hotwire-golang-website This project provides some working examples using Go the hotwire/turbo library published by basecamp.

Dec 29, 2022

Go scripts for finding an API key / some keywords in repository

Go scripts for finding an API key / some keywords in repository

Git-Secret Go scripts for finding an API key / some keywords in repository Update V1.0 🚀 Added some API Key checker Screenshoot 📷 How to Install go

Dec 30, 2022

Yet another StructTag, with some features liked cache and alias.

Yet another StructTag, with some features liked cache and alias.

Nov 1, 2021

Just some random matchers

Just some random matchers

The package provides a matcher interface to match a given value of any types.

Nov 3, 2022
A super simple Lodash like utility library with essential functions that empowers the development in Go
A super simple Lodash like utility library with essential functions that empowers the development in Go

A simple Utility library for Go Go does not provide many essential built in functions when it comes to the data structure such as slice and map. This

Jan 4, 2023
Utility functions for work with the Kubernetes Go-Client

go-k8s-utils This repository contains utils for the work with Kubernetes, in specific with the go-client library. Testing This package contains utils

Dec 14, 2022
Protoc-gen-fieldmask - Generate FieldMask utility functions for protobuf

protoc-gen-fieldmask Generate FieldMask utility functions for protobuf Generated

Aug 20, 2022
This is a small utility that finds unused exported Go symbols (functions, methods ...) in Go

This is a small utility that finds unused exported Go symbols (functions, methods ...) in Go. For all other similar use cases

Nov 8, 2022
Govalid is a data validation library that can validate most data types supported by golang

Govalid is a data validation library that can validate most data types supported by golang. Custom validators can be used where the supplied ones are not enough.

Apr 22, 2022
Golang code-generators used to implement Kubernetes-style API types.

code-generator Golang code-generators used to implement Kubernetes-style API types. Purpose These code-generators can be used in the context of Custom

Dec 30, 2022
Slice conversion between primitive types

sliceconv Sliceconv implements conversions to and from string representations of primitive types on entire slices. The package supports types int, flo

Sep 27, 2022
A better Generic Pool (sync.Pool)
A better Generic Pool (sync.Pool)

This package is a thin wrapper over the Pool provided by the sync package. The Pool is an essential package to obtain maximum performance by reducing the number of memory allocations.

Dec 1, 2022
Package ethtool allows control of the Linux ethtool generic netlink interface.

ethtool Package ethtool allows control of the Linux ethtool generic netlink interface.

Dec 14, 2022
Go library for decoding generic map values into native Go structures and vice versa.

mapstructure mapstructure is a Go library for decoding generic map values to structures and vice versa, while providing helpful error handling. This l

Dec 28, 2022