diff --git a/clipboard_android.go b/clipboard_android.go index c9ce78f..ea1ebfe 100644 --- a/clipboard_android.go +++ b/clipboard_android.go @@ -81,6 +81,7 @@ func watch(ctx context.Context, t Format) <-chan []byte { ti := time.NewTicker(time.Second) last := Read(t) go func() { + defer ti.Stop() for { select { case <-ctx.Done(): diff --git a/clipboard_darwin.go b/clipboard_darwin.go index bcda127..830217d 100644 --- a/clipboard_darwin.go +++ b/clipboard_darwin.go @@ -100,6 +100,7 @@ func watch(ctx context.Context, t Format) <-chan []byte { ti := time.NewTicker(time.Second) lastCount := C.long(C.clipboard_change_count()) go func() { + defer ti.Stop() for { select { case <-ctx.Done(): diff --git a/clipboard_ios.go b/clipboard_ios.go index e027b8c..f1c162f 100644 --- a/clipboard_ios.go +++ b/clipboard_ios.go @@ -59,6 +59,7 @@ func watch(ctx context.Context, t Format) <-chan []byte { ti := time.NewTicker(time.Second) last := Read(t) go func() { + defer ti.Stop() for { select { case <-ctx.Done(): diff --git a/clipboard_linux.go b/clipboard_linux.go index 14ebe95..c516dac 100644 --- a/clipboard_linux.go +++ b/clipboard_linux.go @@ -138,6 +138,7 @@ func watch(ctx context.Context, t Format) <-chan []byte { ti := time.NewTicker(time.Second) last := Read(t) go func() { + defer ti.Stop() for { select { case <-ctx.Done(): diff --git a/clipboard_windows.go b/clipboard_windows.go index bd042cd..77e6440 100644 --- a/clipboard_windows.go +++ b/clipboard_windows.go @@ -404,6 +404,7 @@ func watch(ctx context.Context, t Format) <-chan []byte { go func() { // not sure if we are too slow or the user too fast :) ti := time.NewTicker(time.Second) + defer ti.Stop() cnt, _, _ := getClipboardSequenceNumber.Call() ready <- struct{}{} for {