add remove driver function

This commit is contained in:
Adrian Zuercher
2025-07-30 11:55:30 +02:00
parent e720f0d2d3
commit a39dcc06f4
3 changed files with 84 additions and 2 deletions

View File

@@ -27,3 +27,31 @@ func (t *Topic) AddPublish(pubs ...string) {
slices.Sort(t.Publish)
}
}
func (t *Topic) RemoveSubscription(subs ...string) {
if len(t.Subscribe) == 1 {
t.Subscribe = []string{}
return
}
for _, toDelete := range subs {
for i, a := range t.Subscribe {
if a == toDelete {
t.Subscribe = slices.Delete(t.Subscribe, i, i+1)
}
}
}
}
func (t *Topic) RemovePublish(pubs ...string) {
if len(t.Publish) == 1 {
t.Publish = []string{}
return
}
for _, toDelete := range pubs {
for i, a := range t.Publish {
if a == toDelete {
t.Publish = slices.Delete(t.Publish, i, i+1)
}
}
}
}