Utility functions which I think should be part of the standard library. Only depends on the standard library and golang.org/x/... modules.
| context | Add context utilities | |
| io | Add ReaderFromWriter | |
| net | Fix formatting server_test.go with go fmt | |
| sync/broadcaster | Reformat broadcaster_test.go with gofmt | |
| go.mod | Run "go mod tidy" | |
| go.sum | Initial version: TCP/Unix-socket server | |
| LICENSE.md | Initial version: TCP/Unix-socket server | |
| README.md | Add ReaderFromWriter | |
Antoine Catton's golang utilities
This golang library contains a collections of utility functions which, in my opinion, should be part of the standard library.
This utility library only relies on the go standard library and
golang.org/x/... packages.
It tries to fulfill as much as possible the two following goals:
- Type safety: exensively use generics, try to avoid
anyandreflect. - Cancellability: use and accept
context.Contextas much as possible. Especially when dealing with network. - Light locking: use
sync/atomicand other lightweight concurrency abstractions. Tries to avoid mutex as much as possible.
Provided batteries
Abstractions provided by this library are:
- Network
- Connection server: generic TCP or Unix-domain-socket connection server à la
http.Server.
- Connection server: generic TCP or Unix-domain-socket connection server à la
- Synchronization
- Broadcaster: goroutine-safe channel to broadcast a value to all consumers (named subscriber in this abstraction)
- Context:
- Detach: detaches a context from any deadline, while keeping the state.
- ReattachTo: reattach a context state to another's deadline.
- I/O:
- ReaderFromWriter: allows to convert an
io.Writeinterface into anio.ReadCloserinterface.
- ReaderFromWriter: allows to convert an