diff --git a/journal.go b/journal.go index 3ce4bd1..dfebbe0 100644 --- a/journal.go +++ b/journal.go @@ -266,7 +266,7 @@ func fluxTime(value string) (time.Time, error) { if value == "" { return time.Time{}, core.E("store.fluxTime", "range value is empty", nil) } - value = firstString(core.Split(value, ",")) + value = firstOrEmptyString(core.Split(value, ",")) value = core.Trim(value) if core.HasPrefix(value, "time(v:") && core.HasSuffix(value, ")") { value = core.Trim(core.TrimSuffix(core.TrimPrefix(value, "time(v:"), ")")) diff --git a/scope.go b/scope.go index f7d0b89..08e582e 100644 --- a/scope.go +++ b/scope.go @@ -172,13 +172,13 @@ func (scopedStore *ScopedStore) Count(group string) (int, error) { // Usage example: `keyCount, err := scopedStore.CountAll("config")` // Usage example: `keyCount, err := scopedStore.CountAll()` func (scopedStore *ScopedStore) CountAll(groupPrefix ...string) (int, error) { - return scopedStore.store.CountAll(scopedStore.namespacedGroup(firstString(groupPrefix))) + return scopedStore.store.CountAll(scopedStore.namespacedGroup(firstOrEmptyString(groupPrefix))) } // Usage example: `groupNames, err := scopedStore.Groups("config")` // Usage example: `groupNames, err := scopedStore.Groups()` func (scopedStore *ScopedStore) Groups(groupPrefix ...string) ([]string, error) { - groupNames, err := scopedStore.store.Groups(scopedStore.namespacedGroup(firstString(groupPrefix))) + groupNames, err := scopedStore.store.Groups(scopedStore.namespacedGroup(firstOrEmptyString(groupPrefix))) if err != nil { return nil, err } @@ -193,7 +193,7 @@ func (scopedStore *ScopedStore) Groups(groupPrefix ...string) ([]string, error) func (scopedStore *ScopedStore) GroupsSeq(groupPrefix ...string) iter.Seq2[string, error] { return func(yield func(string, error) bool) { namespacePrefix := scopedStore.namespacePrefix() - for groupName, err := range scopedStore.store.GroupsSeq(scopedStore.namespacedGroup(firstString(groupPrefix))) { + for groupName, err := range scopedStore.store.GroupsSeq(scopedStore.namespacedGroup(firstOrEmptyString(groupPrefix))) { if err != nil { if !yield("", err) { return diff --git a/store.go b/store.go index f71416f..347951c 100644 --- a/store.go +++ b/store.go @@ -372,7 +372,7 @@ func (storeInstance *Store) Groups(groupPrefix ...string) ([]string, error) { // Usage example: `for tenantGroupName, err := range storeInstance.GroupsSeq("tenant-a:") { if err != nil { break }; fmt.Println(tenantGroupName) }` // Usage example: `for groupName, err := range storeInstance.GroupsSeq() { if err != nil { break }; fmt.Println(groupName) }` func (storeInstance *Store) GroupsSeq(groupPrefix ...string) iter.Seq2[string, error] { - actualGroupPrefix := firstString(groupPrefix) + actualGroupPrefix := firstOrEmptyString(groupPrefix) return func(yield func(string, error) bool) { var rows *sql.Rows var err error @@ -412,7 +412,7 @@ func (storeInstance *Store) GroupsSeq(groupPrefix ...string) iter.Seq2[string, e } } -func firstString(values []string) string { +func firstOrEmptyString(values []string) string { if len(values) == 0 { return "" }