Generic types that are missing from Go, including sets, trees, sorted lists, etc.

go-typ

Codacy Badge REUSE status

Generic types that are missing from Go, including sets, trees, sorted lists, etc.

All code is implemented with 0 dependencies and in pure Go code (no CGo).

Compatibility

Requires Go v1.18beta1 or later as the code makes use of generics.

Installation and usage

go get -u gopkg.in/typ.v0

Development

Please read the CONTRIBUTING.md for information about development environment and guidelines.

License

This project is primarily licensed under the MIT license:

  • The Go code in this project is licensed under the MIT license: LICENSES/MIT.txt

  • Documentation is licensed under the Creative Commons Attribution 4.0 International (CC-BY-4.0) license: LICENSES

  • Miscellanious files are licensed under the Creative Commons Zero Universal license (CC0-1.0): LICENSES

  • GitHub Action for REUSE linting (and not any of go-typ's code) is licensed under GNU General Public License 3.0 or later (GPL-3.0-or-later): LICENSES/GPL-3.0-or-later.txt

Copyright © Kalle Fagerberg

Comments
  • Release v4.0.0

    Release v4.0.0

    Changes

    • Added interface sets.Set. (#32)

      • Changed the location of the sets.Set struct to maps.Set.
    • Added sync2.Set, a thread-safe implementation of sets.Set. (#32, thanks @Alexamakans)

    • Added more utility functions to gopkg.in/typ/pkg/maps:

      • Added maps.HasKey. (d65e1b9)
      • Added maps.KeyOf. (#33)
      • Added maps.Keys. (#33)
      • Added maps.Values. (#33)
    • Added maps.Bimap, a bi-directional map. (#34)

    • Changed v3 to v4 and moved all sub-packages by removing the intermediate /pkg/: (#35)

      | Before | After | | ---------------------------- | ------------------------ | | gopkg.in/typ.v3 | gopkg.in/typ.v4 | | gopkg.in/typ.v3/pkg/arrays | gopkg.in/typ.v4/arrays | | gopkg.in/typ.v3/pkg/avl | gopkg.in/typ.v4/avl | | gopkg.in/typ.v3/pkg/chans | gopkg.in/typ.v4/chans | | gopkg.in/typ.v3/pkg/lists | gopkg.in/typ.v4/lists | | gopkg.in/typ.v3/pkg/maps | gopkg.in/typ.v4/maps | | gopkg.in/typ.v3/pkg/sets | gopkg.in/typ.v4/sets | | gopkg.in/typ.v3/pkg/slices | gopkg.in/typ.v4/slices | | gopkg.in/typ.v3/pkg/sync2 | gopkg.in/typ.v4/sync2 |

  • Split up package

    Split up package

    • Incremented version to v3
    • Moved sets and slices to their own packages
    • Removed MakeXOfX functions
    • Moved arrays to own package
    • Removed all null types
    • Moved lists to pkg/lists
    • Moved chans to pkg/chans
    • Moved maps to pkg/maps
    • Moved sync to pkg/sync2
    • Moved AVLTree to pkg/avl
    • Lint fix
    • Renamed syncmap.go -> map.go
  • func: GrowSlice

    func: GrowSlice

    Since Go v1.11's compiler optimizations, the following is sufficient (https://go.dev/doc/go1.11#performance-compiler):

    return append(slice, make([]T, n)...)
    
  • func: ClearMap

    func: ClearMap

    Clear all values in a map. The following is translated by the Go compiler (since v1.11) into an efficient call for clearing the map's internal state (https://go.dev/doc/go1.11#performance-compiler):

    for k := range m {
        delete(m, k)
    }
    
  • func: RecvAll(chan, bufferSize)

    func: RecvAll(chan, bufferSize)

    Read all values from channel until there's no values left in the buffer. I.e. when the select default statement triggers.

    Should have buffer alternative for custom buffer slices.

  • func: Ptr

    func: Ptr

    Returns a pointer to the value. Useful when working with literals.

    Ex:

    typ.Ptr(13) // &int{13}
    typ.Ptr("hello") // &string{"hello"}
    
  • Added typ.Null[T]

    Added typ.Null[T]

    I forked https://github.com/volatiletech/null to complete this. Lot's of type switches, which I'm not that proud of. Any the lack of distinction between byte and uint8 is a loss for sure. No ways around it though.

    Closes #21

  • type: fan-out channel

    type: fan-out channel

    1 publisher Many (or no) subscribers

    Can probably just copy my code from https://github.com/dinkur/dinkur/blob/259e48139bfc82ed542b61afaf299e893b2add3f/internal/obs/obs.go, that code is sufficient.

  • type: Pool

    type: Pool

    Take inspiration from sync: https://pkg.go.dev/sync#Pool

    The pool package is so tightly nit with the Go GC that it's probably best to just add a wrapper

Related tags
A generic Go library for implementations of tries (radix trees), state commitments and proofs of inclusion

trie.go Go library for implementations of tries (radix trees), state commitments and proof of inclusion for large data sets. It implements a generic 2

Aug 3, 2022
Convert arbitrary formats to Go Struct (including json, toml, yaml, etc.)

go2struct Convert arbitrary formats to Go Struct (including json, toml, yaml, etc.) Installation Run the following command under your project: go get

Nov 15, 2022
Custom generic HTTP handler providing automatic JSON decoding/encoding of HTTP request/response to your concrete types

gap Custom generic HTTP handler providing automatic JSON decoding/encoding of HTTP request/response to your concrete types. gap.Wrap allows to use the

Aug 28, 2022
Package iter provides generic, lazy iterators, functions for producing them from primitive types, as well as functions and methods for transforming and consuming them.

iter Package iter provides generic, lazy iterators, functions for producing them from primitive types, as well as functions and methods for transformi

Dec 16, 2022
skipmap is a high-performance concurrent sorted map based on skip list. Up to 3x ~ 10x faster than sync.Map in the typical pattern.
skipmap is a high-performance concurrent sorted map based on skip list. Up to 3x ~ 10x faster than sync.Map in the typical pattern.

Introduction skipmap is a high-performance concurrent map based on skip list. In typical pattern(one million operations, 90%LOAD 9%STORE 1%DELETE), th

Jan 8, 2023
ZSet is an in-memory Redis like sorted set datastructure

zset Getting Started Installing To start using hash, install Go and run go get: $ go get -u github.com/arriqaaq/zset This will retrieve the library. U

Oct 13, 2022
Type-safe, zero-allocation sets for Go

Set Package set is a type-safe, zero-allocation port of the excellent package fatih/set. It contains sets for most of the basic types and you can gene

Jan 5, 2023
Sync distributed sets using bloom filters

goSetReconciliation An implementation to sync distributed sets using bloom filters. Based on the paper "Low complexity set reconciliation using Bloom

Jan 4, 2022
Distributed merge sort for large sets across nodes in a network

distMergeSort An implementation of mergesort distributed across nodes used to sort large sets. Introduction Merge sort partitions sets so that they ca

Jul 8, 2022
Adaptive Radix Trees implemented in Go

An Adaptive Radix Tree Implementation in Go This library provides a Go implementation of the Adaptive Radix Tree (ART). Features: Lookup performance s

Dec 30, 2022
A Left-Leaning Red-Black (LLRB) implementation of balanced binary search trees for Google Go

GoLLRB GoLLRB is a Left-Leaning Red-Black (LLRB) implementation of 2-3 balanced binary search trees in Go Language. Overview As of this writing and to

Dec 23, 2022
Golang implementation of Radix trees

go-radix Provides the radix package that implements a radix tree. The package only provides a single Tree implementation, optimized for sparse nodes.

Dec 30, 2022
A go implementation of Verkle trees

go-verkle A very experimental implementation of Verkle trees. When production-ready, the code is to be split between go-kzg and go-ethereum. Notes Nod

Jan 8, 2023
A Go implementation of a radix tree, that uses binary searches to speed up insert, retrieve and delete operations on dense trees

radixs A Go implementation of a radix tree, that uses binary searches to speed up insert, retrieve and delete operations on dense trees. This implemen

Feb 14, 2022
💯 Go Struct and Field validation, including Cross Field, Cross Struct, Map, Slice and Array diving

Package validator implements value validations for structs and individual fields based on tags.

Nov 9, 2022
Clone a directory (including permissions) into S3 for File Gateway usage

s3-tree-clone Clone a filesystem tree to S3 (including metadata), skipping over files that are already synced, in a manner compatible with AWS File Ga

Dec 2, 2021
Juniper is an extension to the Go standard library using generics, including containers, iterators, and streams.

Juniper Juniper is a library of extensions to the Go standard library using generics, including containers, iterators, and streams. container/tree con

Dec 25, 2022
Nullable Go types that can be marshalled/unmarshalled to/from JSON.

Nullable Go types Description This package provides nullable Go types for bool, float64, int64, int32, string and time.Time replacing sql.NullString,

Dec 12, 2022
Null Types, Safe primitive type conversion and fetching value from complex structures.

Typ Typ is a library providing a powerful interface to impressive user experience with conversion and fetching data from built-in types in Golang Feat

Sep 26, 2022