diff --git a/Collection.go b/Collection.go index 8271d33..94c87e9 100644 --- a/Collection.go +++ b/Collection.go @@ -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 { diff --git a/README.md b/README.md index 986c40e..b9b22cc 100644 --- a/README.md +++ b/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 ``` +## 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