1
0
Fork
You've already forked go-utils
0
Utility functions which I think should be part of the standard library. Only depends on the standard library and golang.org/x/... modules.
  • Go 100%
Find a file
2023年06月01日 21:22:30 +02:00
context Add context utilities 2023年05月19日 01:44:50 +02:00
io Add ReaderFromWriter 2023年06月01日 21:22:30 +02:00
net Fix formatting server_test.go with go fmt 2023年05月19日 01:22:55 +02:00
sync/broadcaster Reformat broadcaster_test.go with gofmt 2023年05月19日 01:33:08 +02:00
go.mod Run "go mod tidy" 2023年05月19日 01:50:59 +02:00
go.sum Initial version: TCP/Unix-socket server 2023年05月18日 21:06:38 +02:00
LICENSE.md Initial version: TCP/Unix-socket server 2023年05月18日 21:06:38 +02:00
README.md Add ReaderFromWriter 2023年06月01日 21:22:30 +02:00

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 any and reflect.
  • Cancellability: use and accept context.Context as much as possible. Especially when dealing with network.
  • Light locking: use sync/atomic and 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.
  • 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.Write interface into an io.ReadCloser interface.