fix: make slug package thread safe

This commit is contained in:
2026-07-16 20:35:10 +07:00
parent d9f3737797
commit 1c591882cc
+7
View File
@@ -1,11 +1,14 @@
package slug
import "sync"
type Slug interface {
String() string
Set(slug string)
}
type slug struct {
mu sync.RWMutex
slug string
}
@@ -16,9 +19,13 @@ func New() Slug {
}
func (s *slug) String() string {
s.mu.RLock()
defer s.mu.RUnlock()
return s.slug
}
func (s *slug) Set(slug string) {
s.mu.Lock()
defer s.mu.Unlock()
s.slug = slug
}