Replace github.com/unknwon/com with stdlib and internal helpers (#8148)

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: Joe Chen <jc@unknwon.io>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Copilot
2026-02-05 22:08:54 -05:00
committed by GitHub
parent 6d56105f8f
commit bf17cc6c69
38 changed files with 259 additions and 171 deletions

View File

@@ -1,7 +1,7 @@
package sync
import (
"github.com/unknwon/com"
"fmt"
)
// UniqueQueue is a queue which guarantees only one instance of same
@@ -35,7 +35,7 @@ func (q *UniqueQueue) Queue() <-chan string {
// Exist returns true if there is an instance with given identity
// exists in the queue.
func (q *UniqueQueue) Exist(id any) bool {
return q.table.IsRunning(com.ToStr(id))
return q.table.IsRunning(fmt.Sprintf("%v", id))
}
// AddFunc adds new instance to the queue with a custom runnable function,
@@ -45,7 +45,7 @@ func (q *UniqueQueue) AddFunc(id any, fn func()) {
return
}
idStr := com.ToStr(id)
idStr := fmt.Sprintf("%v", id)
q.table.Lock()
q.table.pool[idStr] = true
if fn != nil {
@@ -62,5 +62,5 @@ func (q *UniqueQueue) Add(id any) {
// Remove removes instance from the queue.
func (q *UniqueQueue) Remove(id any) {
q.table.Stop(com.ToStr(id))
q.table.Stop(fmt.Sprintf("%v", id))
}