https://github.com/gtramontina/go-extlib
Go Extended Lib
https://github.com/gtramontina/go-extlib
extended generic-types go golang stdlib stdlib-extras
Last synced: 2 months ago
JSON representation
Go Extended Lib
- Host: GitHub
- URL: https://github.com/gtramontina/go-extlib
- Owner: gtramontina
- License: mit
- Created: 2021-10-09T05:54:35.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-03-05T10:52:30.000Z (over 2 years ago)
- Last Synced: 2025-04-12T07:07:46.819Z (2 months ago)
- Topics: extended, generic-types, go, golang, stdlib, stdlib-extras
- Language: Go
- Homepage:
- Size: 288 KB
- Stars: 11
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
![]()
![]()
⚠️ Note: This is still an experiment.
![]()
## Motivation
My main motivation was to try out generics in Go. I jumped straight into the usual suspects: [`Filter`](https://github.com/gtramontina/go-extlib/blob/main/collections/filter.go) and [`Map`](https://github.com/gtramontina/go-extlib/blob/main/collections/map.go). When testing these, I saw the need for assertion functions: another opportunity to exercise some more generics! It is now part of this ext-lib under lives as an [testing/assert](https://github.com/gtramontina/go-extlib/blob/main/testing/assert).
Later I thought it would be nice to implement [`Set`](https://github.com/gtramontina/go-extlib/tree/main/set), and then [`HashMap`](https://github.com/gtramontina/go-extlib/tree/main/hashmap), with which I got carried away and ended up implementing a somewhat naïve [hasher](https://github.com/gtramontina/go-extlib/blob/main/internal/hash/hash.go) (you can read more on the rationale on [this commit](https://github.com/gtramontina/go-extlib/commit/808ac8236c433587c4dc2f85479c1189a5df6010)).
When I realized, I was already having fun with [`Maybe`](https://github.com/gtramontina/go-extlib/tree/main/maybe), [`Either`](https://github.com/gtramontina/go-extlib/tree/main/either) and [`Result`](https://github.com/gtramontina/go-extlib/tree/main/result). Here is where I stumbled upon some limitations of Go generics. Right when I was experimenting with it, I came across a blog post by [@hypirion](https://github.com/hypirion) titled "[Type-Safe HTTP Servers in Go via Generics](https://hypirion.com/musings/type-safe-http-servers-in-go-via-generics)" where the author bumps into these same limitations.
When writing software in Go, I've always wanted slightly higher level constructs, especially to represent business domain concepts. Some may say I haven't fully embraced Go. Perhaps I haven't 🤷. But I sure know people who'd also like to go up in abstraction a tad bit.
Hope this is enough motivation… 😅
⚠️ As the note above says, this is an experiment and no attention was paid to performance or allocations.
## The ExtLib
🚧 This section is a work in progress.
---
Gopher: gopherize.me