Skip to content

Commit

Permalink
Add tags api
Browse files Browse the repository at this point in the history
  • Loading branch information
Tnze committed Jul 27, 2024
1 parent 3137528 commit 66b3b11
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 33 deletions.
33 changes: 0 additions & 33 deletions registry/README.md

This file was deleted.

12 changes: 12 additions & 0 deletions registry/registry.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package registry

import "slices"

Check failure on line 3 in registry/registry.go

View workflow job for this annotation

GitHub Actions / Test (1.20)

package slices is not in GOROOT (/opt/hostedtoolcache/go/1.20.14/x64/src/slices)

type Registry[E any] struct {
keys map[string]int32
values []E
Expand Down Expand Up @@ -47,6 +49,16 @@ func (r *Registry[E]) Put(name string, data E) (id int32, val *E) {
return
}

// Tags

func (r *Registry[E]) Tag(tag string) []*E {
return slices.Clone(r.tags[tag])
}

func (r *Registry[E]) ClearTags() {
r.tags = make(map[string][]*E)
}

// func (r *Registry[E]) BindTags(tag string, ids []int32) error {
// values := make([]*E, len(ids))
// for i, id := range ids {
Expand Down

0 comments on commit 66b3b11

Please sign in to comment.