Removed an allocation
This commit is contained in:
parent
022107d796
commit
8c5a1da093
@ -27,7 +27,7 @@ type collection[T any] struct {
|
|||||||
|
|
||||||
// New creates a new collection with the given name.
|
// New creates a new collection with the given name.
|
||||||
func New[T any](directories ...string) (*collection[T], error) {
|
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()
|
home, err := os.UserHomeDir()
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
13
README.md
13
README.md
@ -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
|
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
|
## Example
|
||||||
|
|
||||||
```go
|
```go
|
||||||
|
Loading…
Reference in New Issue
Block a user