Removed an allocation

This commit is contained in:
Eduard Urbach 2023-07-06 15:34:57 +02:00
parent 022107d796
commit 8c5a1da093
Signed by: akyoto
GPG Key ID: C874F672B1AF20C0
2 changed files with 14 additions and 1 deletions

View File

@ -27,7 +27,7 @@ type collection[T any] struct {
// New creates a new collection with the given name.
func New[T any](directories ...string) (*collection[T], error) {
name := reflect.TypeOf(*new(T)).Name()
name := reflect.TypeOf((*T)(nil)).Elem().Name()
home, err := os.UserHomeDir()
if err != nil {

View File

@ -10,6 +10,19 @@ If you like, you can operate on your entire data with classic UNIX tools.
go get git.akyoto.dev/go/ocean
```
## API
```go
type Collection[T any] interface {
All() <-chan *T
Clear()
Delete(key string)
Exists(key string) bool
Get(key string) (value *T, ok bool)
Set(key string, value *T)
}
```
## Example
```go