diff --git a/README.md b/README.md index eeb61a2..16eba8e 100755 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -[![Go](https://github.com/tempura-shrimp/co/actions/workflows/go.yml/badge.svg)](https://github.com/tempura-shrimp/co/actions/workflows/go.yml) +[![Go](https://github.com/tempurai/co/actions/workflows/go.yml/badge.svg)](https://github.com/tempurai/co/actions/workflows/go.yml) # Co @@ -28,7 +28,7 @@ However, even though I have mentioned a lot of ReactiveX patterns above. I do no ## APIs -https://godoc.org/go.tempura.ink/co +https://pkg.go.dev/github.com/tempurai/co ### Promising functions: @@ -78,7 +78,19 @@ https://godoc.org/go.tempura.ink/co ## Getting started -Navigate to your project base and `go get go.tempura.ink/co` +Navigate to your project base and `go get github.com/tempurai/co`. + +If you are in an environment without access to the public Go proxy, you can fetch directly: + +```bash +GOPROXY=direct go get github.com/tempurai/co +``` + +If module checksum verification is blocked in your environment, you can also disable it: + +```bash +GOPROXY=direct GOSUMDB=off go get github.com/tempurai/co +``` ## Examples @@ -166,7 +178,7 @@ Pool benchmark ```golang goos: darwin goarch: amd64 -pkg: go.tempura.ink/co/benchmark +pkg: github.com/tempurai/co/benchmark cpu: Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz BenchmarkUnmarshalLargeJSONWithSequence-12 50 45000332 ns/op 11435352 B/op 137058 allocs/op BenchmarkUnmarshalLargeJSONWithAwaitAll-12 50 9901537 ns/op 11207428 B/op 134323 allocs/op @@ -175,5 +187,5 @@ BenchmarkUnmarshalLargeJSONWithAnts-12 50 100755 BenchmarkUnmarshalLargeJSONWithWorkPool-12 50 9658117 ns/op 11206981 B/op 134322 allocs/op BenchmarkUnmarshalLargeJSONWithDispatchPool-12 50 10893923 ns/op 11207039 B/op 134322 allocs/op PASS -ok go.tempura.ink/co/benchmark 6.793s +ok github.com/tempurai/co/benchmark 6.793s ``` diff --git a/action.go b/action.go index e93ec2d..56b717e 100644 --- a/action.go +++ b/action.go @@ -3,7 +3,7 @@ package co import ( "sync" - syncx "go.tempura.ink/co/internal/syncx" + syncx "github.com/tempurai/co/internal/syncx" ) type Action[E any] struct { diff --git a/action_await_all.go b/action_await_all.go index 296083a..be6272e 100644 --- a/action_await_all.go +++ b/action_await_all.go @@ -3,7 +3,7 @@ package co import ( "sync" - syncx "go.tempura.ink/co/internal/syncx" + syncx "github.com/tempurai/co/internal/syncx" ) type actionAwait[R any] struct { diff --git a/action_await_race.go b/action_await_race.go index 9195462..664f1a2 100755 --- a/action_await_race.go +++ b/action_await_race.go @@ -3,7 +3,7 @@ package co import ( "sync" - syncx "go.tempura.ink/co/internal/syncx" + syncx "github.com/tempurai/co/internal/syncx" ) type actionRace[R any] struct { diff --git a/action_await_test.go b/action_await_test.go index ebb3f44..69052d4 100755 --- a/action_await_test.go +++ b/action_await_test.go @@ -9,13 +9,13 @@ import ( "time" "github.com/smartystreets/goconvey/convey" - "go.tempura.ink/co" + "github.com/tempurai/co" ) func TestAwaitAll(t *testing.T) { convey.Convey("given a sequential tasks", t, func() { handlers := make([]func() (int, error), 0) - for i := 0; i < 1000; i++ { + for i := 0; i < 200; i++ { i := i handlers = append(handlers, func() (int, error) { return i + 1, nil @@ -27,7 +27,7 @@ func TestAwaitAll(t *testing.T) { convey.Convey("The responded value should be valid", func() { expected, actuals := []int{}, []int{} - for i := 0; i < 1000; i++ { + for i := 0; i < 200; i++ { expected = append(expected, i+1) actuals = append(actuals, responses[i].GetValue()) } @@ -41,11 +41,12 @@ func TestAwaitRace(t *testing.T) { runtime.GOMAXPROCS(runtime.NumCPU() * 2) convey.Convey("given a sequential tasks", t, func() { + baseDelay := 10 * time.Millisecond handlers := make([]func() (int, error), 0) - for i := 0; i < 100; i++ { + for i := 0; i < 10; i++ { i := i handlers = append(handlers, func() (int, error) { - time.Sleep(time.Second * time.Duration(i+1)) + time.Sleep(baseDelay * time.Duration(i+1)) return i + 1, nil }) } @@ -64,8 +65,9 @@ func TestAwaitAny(t *testing.T) { runtime.GOMAXPROCS(runtime.NumCPU() * 2) convey.Convey("given a sequential tasks", t, func() { + baseDelay := 10 * time.Millisecond handlers := make([]func() (int, error), 0) - for i := 0; i < 100; i++ { + for i := 0; i < 10; i++ { i := i err := fmt.Errorf("Determined value") @@ -74,7 +76,7 @@ func TestAwaitAny(t *testing.T) { } handlers = append(handlers, func() (int, error) { - time.Sleep(time.Second * time.Duration(i+1)) + time.Sleep(baseDelay * time.Duration(i+1)) return i + 1, err }) } diff --git a/async_adjacent_filter_sequence.go b/async_adjacent_filter_sequence.go index a9c2833..41650f1 100644 --- a/async_adjacent_filter_sequence.go +++ b/async_adjacent_filter_sequence.go @@ -1,7 +1,7 @@ package co import ( - syncx "go.tempura.ink/co/internal/syncx" + syncx "github.com/tempurai/co/internal/syncx" ) type AsyncAdjacentFilterSequence[R any] struct { diff --git a/async_adjacent_filter_sequence_test.go b/async_adjacent_filter_sequence_test.go index 0f62890..6b870db 100644 --- a/async_adjacent_filter_sequence_test.go +++ b/async_adjacent_filter_sequence_test.go @@ -4,7 +4,7 @@ import ( "testing" "github.com/smartystreets/goconvey/convey" - "go.tempura.ink/co" + "github.com/tempurai/co" ) func TestAsyncAdjacentFilterSequence(t *testing.T) { diff --git a/async_any_sequence.go b/async_any_sequence.go index 84c365c..3d5ca4a 100644 --- a/async_any_sequence.go +++ b/async_any_sequence.go @@ -3,8 +3,8 @@ package co import ( "sync" - "go.tempura.ink/co/ds/queue" - syncx "go.tempura.ink/co/internal/syncx" + "github.com/tempurai/co/ds/queue" + syncx "github.com/tempurai/co/internal/syncx" ) type AsyncAnySequence[R any] struct { diff --git a/async_any_sequence_test.go b/async_any_sequence_test.go index 200a760..0ef7ee5 100644 --- a/async_any_sequence_test.go +++ b/async_any_sequence_test.go @@ -5,8 +5,8 @@ import ( "time" "github.com/smartystreets/goconvey/convey" - "go.tempura.ink/co" - "golang.org/x/exp/slices" + "github.com/tempurai/co" + "slices" ) func TestAsyncAnySequence(t *testing.T) { diff --git a/async_buffer_time_sequence.go b/async_buffer_time_sequence.go index f6bb3c1..5b1b953 100644 --- a/async_buffer_time_sequence.go +++ b/async_buffer_time_sequence.go @@ -4,7 +4,7 @@ import ( "sync" "time" - syncx "go.tempura.ink/co/internal/syncx" + syncx "github.com/tempurai/co/internal/syncx" ) type AsyncBufferTimeSequence[R any, T []R] struct { @@ -46,9 +46,11 @@ type asyncBufferTimeSequenceIterator[R any, T []R] struct { previousTime time.Time bufferedData *List[T] - runOnce sync.Once - sourceEnded bool - bufferWait *syncx.Condx + runOnce sync.Once + sourceEnded bool + bufferWait *syncx.Condx + tickerStop chan struct{} + tickerStopOnce sync.Once } func (it *asyncBufferTimeSequenceIterator[R, T]) intervalPassed() bool { @@ -58,6 +60,7 @@ func (it *asyncBufferTimeSequenceIterator[R, T]) intervalPassed() bool { func (it *asyncBufferTimeSequenceIterator[R, T]) startBuffer() { it.runOnce.Do(func() { it.previousTime = time.Now() + it.tickerStop = make(chan struct{}) syncx.SafeGo(func() { for op := it.previousIterator.next(); op.valid; op = it.previousIterator.next() { @@ -71,14 +74,38 @@ func (it *asyncBufferTimeSequenceIterator[R, T]) startBuffer() { if reachedInterval { it.bufferWait.Broadcastify(&syncx.BroadcastOption{ - PreProcessFn: func() { it.previousTime = time.Now() }}, - ) + PreProcessFn: func() { it.previousTime = time.Now() }, + }) } } it.bufferWait.Broadcastify(&syncx.BroadcastOption{ - PreProcessFn: func() { it.sourceEnded = true }}, - ) + PreProcessFn: func() { + it.sourceEnded = true + it.stopTicker() + }, + }) }) + + if it.interval > 0 { + syncx.SafeGo(func() { + ticker := time.NewTicker(it.interval) + defer ticker.Stop() + for { + select { + case <-ticker.C: + it.bufferWait.Broadcastify(&syncx.BroadcastOption{}) + case <-it.tickerStop: + return + } + } + }) + } + }) +} + +func (it *asyncBufferTimeSequenceIterator[R, T]) stopTicker() { + it.tickerStopOnce.Do(func() { + close(it.tickerStop) }) } diff --git a/async_buffer_time_sequence_test.go b/async_buffer_time_sequence_test.go index 7e47445..7064ce3 100644 --- a/async_buffer_time_sequence_test.go +++ b/async_buffer_time_sequence_test.go @@ -5,7 +5,7 @@ import ( "time" "github.com/smartystreets/goconvey/convey" - "go.tempura.ink/co" + "github.com/tempurai/co" ) func TestAsyncBufferTimeSequence(t *testing.T) { diff --git a/async_combine_latest_sequence.go b/async_combine_latest_sequence.go index 27cfab4..e729102 100644 --- a/async_combine_latest_sequence.go +++ b/async_combine_latest_sequence.go @@ -3,8 +3,8 @@ package co import ( "sync" - "go.tempura.ink/co/ds/queue" - syncx "go.tempura.ink/co/internal/syncx" + "github.com/tempurai/co/ds/queue" + syncx "github.com/tempurai/co/internal/syncx" ) type asyncCombineLatestFn[R any] func([]any) R diff --git a/async_combine_latest_sequence_test.go b/async_combine_latest_sequence_test.go index b85d1df..ef0826f 100644 --- a/async_combine_latest_sequence_test.go +++ b/async_combine_latest_sequence_test.go @@ -4,8 +4,8 @@ import ( "testing" "github.com/smartystreets/goconvey/convey" - "go.tempura.ink/co" - "golang.org/x/exp/slices" + "github.com/tempurai/co" + "slices" ) func checkCombineLatest[T comparable](c convey.C, a [][]T, l ...[]T) { diff --git a/async_compacted_sequence.go b/async_compacted_sequence.go index dcd04e5..e620550 100644 --- a/async_compacted_sequence.go +++ b/async_compacted_sequence.go @@ -1,6 +1,6 @@ package co -import syncx "go.tempura.ink/co/internal/syncx" +import syncx "github.com/tempurai/co/internal/syncx" type AsyncCompactedSequence[R comparable] struct { *asyncSequence[R] diff --git a/async_compacted_sequence_test.go b/async_compacted_sequence_test.go index b8f9658..9be096a 100644 --- a/async_compacted_sequence_test.go +++ b/async_compacted_sequence_test.go @@ -4,7 +4,7 @@ import ( "testing" "github.com/smartystreets/goconvey/convey" - "go.tempura.ink/co" + "github.com/tempurai/co" ) type vData struct{ v int } diff --git a/async_debounce_sequence.go b/async_debounce_sequence.go index 433ce51..4dfbbca 100644 --- a/async_debounce_sequence.go +++ b/async_debounce_sequence.go @@ -4,8 +4,8 @@ import ( "sync" "time" - "go.tempura.ink/co/ds/queue" - syncx "go.tempura.ink/co/internal/syncx" + "github.com/tempurai/co/ds/queue" + syncx "github.com/tempurai/co/internal/syncx" ) type AsyncDebounceSequence[R any] struct { diff --git a/async_debounce_sequence_test.go b/async_debounce_sequence_test.go index 97af657..a17819a 100644 --- a/async_debounce_sequence_test.go +++ b/async_debounce_sequence_test.go @@ -5,7 +5,7 @@ import ( "time" "github.com/smartystreets/goconvey/convey" - "go.tempura.ink/co" + "github.com/tempurai/co" ) func TestAsyncDebounceSequence(t *testing.T) { diff --git a/async_flatten_sequence_test.go b/async_flatten_sequence_test.go index 266d44f..43cd702 100644 --- a/async_flatten_sequence_test.go +++ b/async_flatten_sequence_test.go @@ -4,7 +4,7 @@ import ( "testing" "github.com/smartystreets/goconvey/convey" - "go.tempura.ink/co" + "github.com/tempurai/co" ) func TestAsyncFlattenSequence(t *testing.T) { diff --git a/async_map_sequence.go b/async_map_sequence.go index 0854a69..44c522b 100644 --- a/async_map_sequence.go +++ b/async_map_sequence.go @@ -1,6 +1,6 @@ package co -import syncx "go.tempura.ink/co/internal/syncx" +import syncx "github.com/tempurai/co/internal/syncx" type AsyncMapSequence[R, T any] struct { *asyncSequence[T] diff --git a/async_map_sequence_test.go b/async_map_sequence_test.go index 359bd7a..94b81ef 100644 --- a/async_map_sequence_test.go +++ b/async_map_sequence_test.go @@ -5,7 +5,7 @@ import ( "testing" "github.com/smartystreets/goconvey/convey" - "go.tempura.ink/co" + "github.com/tempurai/co" ) func TestAsyncMapSequence(t *testing.T) { diff --git a/async_merged_sequence_test.go b/async_merged_sequence_test.go index cf362ac..beebad1 100644 --- a/async_merged_sequence_test.go +++ b/async_merged_sequence_test.go @@ -4,7 +4,7 @@ import ( "testing" "github.com/smartystreets/goconvey/convey" - "go.tempura.ink/co" + "github.com/tempurai/co" ) func TestAsyncMergedSequence(t *testing.T) { diff --git a/async_multicast_sequence.go b/async_multicast_sequence.go index 15fe281..6ff61d5 100644 --- a/async_multicast_sequence.go +++ b/async_multicast_sequence.go @@ -4,8 +4,8 @@ import ( "log" "sync" - "go.tempura.ink/co/ds/queue" - syncx "go.tempura.ink/co/internal/syncx" + "github.com/tempurai/co/ds/queue" + syncx "github.com/tempurai/co/internal/syncx" ) type AsyncMulticastSequence[R any] struct { diff --git a/async_multicast_sequence_test.go b/async_multicast_sequence_test.go index 736017d..203ecd6 100644 --- a/async_multicast_sequence_test.go +++ b/async_multicast_sequence_test.go @@ -5,7 +5,7 @@ import ( "testing" "github.com/smartystreets/goconvey/convey" - "go.tempura.ink/co" + "github.com/tempurai/co" ) func TestAsyncMulticastSequence(t *testing.T) { diff --git a/async_pairwise_sequence_test.go b/async_pairwise_sequence_test.go index dbf7e54..d9a4ffe 100644 --- a/async_pairwise_sequence_test.go +++ b/async_pairwise_sequence_test.go @@ -5,7 +5,7 @@ import ( "testing" "github.com/smartystreets/goconvey/convey" - "go.tempura.ink/co" + "github.com/tempurai/co" ) func TestAsyncPairwiseSequence(t *testing.T) { diff --git a/async_partition_sequence_test.go b/async_partition_sequence_test.go index 253a3bf..9e96ffc 100644 --- a/async_partition_sequence_test.go +++ b/async_partition_sequence_test.go @@ -4,7 +4,7 @@ import ( "testing" "github.com/smartystreets/goconvey/convey" - "go.tempura.ink/co" + "github.com/tempurai/co" ) func TestAsyncPartitionSequence(t *testing.T) { diff --git a/async_round_trip.go b/async_round_trip.go index 9b9ac65..4d95adf 100644 --- a/async_round_trip.go +++ b/async_round_trip.go @@ -4,8 +4,8 @@ import ( "sync" "sync/atomic" - "go.tempura.ink/co/ds/pool" - syncx "go.tempura.ink/co/internal/syncx" + "github.com/tempurai/co/ds/pool" + syncx "github.com/tempurai/co/internal/syncx" ) type seqItem[R any] struct { diff --git a/async_round_trip_test.go b/async_round_trip_test.go index 28c1111..ac69e4a 100644 --- a/async_round_trip_test.go +++ b/async_round_trip_test.go @@ -7,7 +7,7 @@ import ( "time" "github.com/smartystreets/goconvey/convey" - "go.tempura.ink/co" + "github.com/tempurai/co" ) func TestAsyncRoundTrip(t *testing.T) { diff --git a/async_sequence.go b/async_sequence.go index 5b6992f..9850976 100644 --- a/async_sequence.go +++ b/async_sequence.go @@ -3,7 +3,7 @@ package co import ( "sync" - syncx "go.tempura.ink/co/internal/syncx" + syncx "github.com/tempurai/co/internal/syncx" ) type asyncSequence[R any] struct { diff --git a/async_subject.go b/async_subject.go index c5b8c7e..f75981e 100644 --- a/async_subject.go +++ b/async_subject.go @@ -1,7 +1,7 @@ package co import ( - syncx "go.tempura.ink/co/internal/syncx" + syncx "github.com/tempurai/co/internal/syncx" ) type AsyncSubject[R any] struct { diff --git a/async_subject_test.go b/async_subject_test.go index e918ebb..d40e6f0 100644 --- a/async_subject_test.go +++ b/async_subject_test.go @@ -5,7 +5,7 @@ import ( "time" "github.com/smartystreets/goconvey/convey" - "go.tempura.ink/co" + "github.com/tempurai/co" ) func TestAsyncSubject(t *testing.T) { diff --git a/async_zip_sequence_test.go b/async_zip_sequence_test.go index c3c6dd1..fbaf127 100644 --- a/async_zip_sequence_test.go +++ b/async_zip_sequence_test.go @@ -4,7 +4,7 @@ import ( "testing" "github.com/smartystreets/goconvey/convey" - "go.tempura.ink/co" + "github.com/tempurai/co" ) func checkZip[T comparable](c convey.C, a [][]T, l ...[]T) { diff --git a/benchmark/go.mod b/benchmark/go.mod index e0f3474..60159cf 100644 --- a/benchmark/go.mod +++ b/benchmark/go.mod @@ -1,15 +1,14 @@ -module go.tempura.ink/co/benchmark +module github.com/tempurai/co/benchmark -go 1.18 +go 1.22 require ( github.com/Jeffail/tunny v0.1.4 - go.tempura.ink/co v0.0.0-00010101000000-000000000000 + github.com/tempurai/co v0.0.0-00010101000000-000000000000 ) require ( github.com/panjf2000/ants/v2 v2.5.0 // indirect - golang.org/x/exp v0.0.0-20220328175248-053ad81199eb // indirect ) -replace go.tempura.ink/co => ../. +replace github.com/tempurai/co => ../. diff --git a/benchmark/go.sum b/benchmark/go.sum index 3b77981..2897176 100644 --- a/benchmark/go.sum +++ b/benchmark/go.sum @@ -6,5 +6,3 @@ github.com/panjf2000/ants/v2 v2.5.0 h1:1rWGWSnxCsQBga+nQbA4/iY6VMeNoOIAM0ZWh9u3q github.com/panjf2000/ants/v2 v2.5.0/go.mod h1:cU93usDlihJZ5CfRGNDYsiBYvoilLvBF5Qp/BT2GNRE= github.com/smartystreets/assertions v1.2.0 h1:42S6lae5dvLc7BrLu/0ugRtcFVjoJNMC/N3yZFZkDFs= github.com/smartystreets/goconvey v1.7.2 h1:9RBaZCeXEQ3UselpuwUQHltGVXvdwm6cv1hgR6gDIPg= -golang.org/x/exp v0.0.0-20220328175248-053ad81199eb h1:pC9Okm6BVmxEw76PUu0XUbOTQ92JX11hfvqTjAV3qxM= -golang.org/x/exp v0.0.0-20220328175248-053ad81199eb/go.mod h1:lgLbSvA5ygNOMpwM/9anMpWVlVJ7Z+cHWq/eFuinpGE= diff --git a/benchmark/pool_fib_test.go b/benchmark/pool_fib_test.go index d5b96e7..00f7a47 100644 --- a/benchmark/pool_fib_test.go +++ b/benchmark/pool_fib_test.go @@ -6,8 +6,8 @@ import ( "github.com/Jeffail/tunny" "github.com/panjf2000/ants/v2" - "go.tempura.ink/co" - "go.tempura.ink/co/ds/pool" + "github.com/tempurai/co" + "github.com/tempurai/co/ds/pool" ) var ( diff --git a/benchmark/pool_large_json_test.go b/benchmark/pool_large_json_test.go index 3dfcb1b..42f1fd1 100644 --- a/benchmark/pool_large_json_test.go +++ b/benchmark/pool_large_json_test.go @@ -10,8 +10,8 @@ import ( "github.com/Jeffail/tunny" "github.com/panjf2000/ants/v2" - "go.tempura.ink/co" - "go.tempura.ink/co/ds/pool" + "github.com/tempurai/co" + "github.com/tempurai/co/ds/pool" ) var ( diff --git a/cond_ch.go b/cond_ch.go index a86ce49..6e7689d 100644 --- a/cond_ch.go +++ b/cond_ch.go @@ -1,5 +1,5 @@ package co -import syncx "go.tempura.ink/co/internal/syncx" +import syncx "github.com/tempurai/co/internal/syncx" type Condx = syncx.Condx diff --git a/ds/pool/dispatcher.go b/ds/pool/dispatcher.go index cf09769..112d2d2 100644 --- a/ds/pool/dispatcher.go +++ b/ds/pool/dispatcher.go @@ -4,8 +4,8 @@ import ( "sync" "sync/atomic" - "go.tempura.ink/co/ds/queue" - syncx "go.tempura.ink/co/internal/syncx" + "github.com/tempurai/co/ds/queue" + syncx "github.com/tempurai/co/internal/syncx" ) func NewDispatchPool[K any](maxWorkers int) *DispatcherPool[K] { diff --git a/ds/pool/dispatcher_test.go b/ds/pool/dispatcher_test.go index d3bb8ff..b3b9710 100644 --- a/ds/pool/dispatcher_test.go +++ b/ds/pool/dispatcher_test.go @@ -4,7 +4,7 @@ import ( "testing" "github.com/smartystreets/goconvey/convey" - "go.tempura.ink/co/ds/pool" + "github.com/tempurai/co/ds/pool" ) func TestDispatchPool(t *testing.T) { diff --git a/ds/pool/pool.go b/ds/pool/pool.go index 2e45664..e28d74d 100644 --- a/ds/pool/pool.go +++ b/ds/pool/pool.go @@ -4,7 +4,7 @@ import ( "sync" "sync/atomic" - syncx "go.tempura.ink/co/internal/syncx" + syncx "github.com/tempurai/co/internal/syncx" ) type poolBasic[K any] struct { diff --git a/ds/pool/worker.go b/ds/pool/worker.go index a87f68b..84665cf 100644 --- a/ds/pool/worker.go +++ b/ds/pool/worker.go @@ -4,15 +4,15 @@ import ( "runtime" "sync/atomic" - "go.tempura.ink/co/ds/queue" - syncx "go.tempura.ink/co/internal/syncx" + "github.com/tempurai/co/ds/queue" + syncx "github.com/tempurai/co/internal/syncx" ) func NewWorkerPool[K any](maxWorkers int) *WorkerPool[K] { p := &WorkerPool[K]{ poolBasic: newPoolBasic[K](), - workers: make([]*Worker[K], maxWorkers), + workers: make([]*Worker[K], 0, maxWorkers), loadQueue: queue.NewQueue[*job[K]](), } diff --git a/ds/pool/worker_test.go b/ds/pool/worker_test.go index f3e780a..fe09466 100644 --- a/ds/pool/worker_test.go +++ b/ds/pool/worker_test.go @@ -4,7 +4,7 @@ import ( "testing" "github.com/smartystreets/goconvey/convey" - "go.tempura.ink/co/ds/pool" + "github.com/tempurai/co/ds/pool" ) func TestWorkerPool(t *testing.T) { diff --git a/ds/queue/multi_receiver_queue_test.go b/ds/queue/multi_receiver_queue_test.go index 63f8788..f049a6c 100644 --- a/ds/queue/multi_receiver_queue_test.go +++ b/ds/queue/multi_receiver_queue_test.go @@ -7,8 +7,8 @@ import ( "testing" "github.com/smartystreets/goconvey/convey" - "go.tempura.ink/co/ds/queue" - "golang.org/x/exp/slices" + "github.com/tempurai/co/ds/queue" + "slices" ) func TestMultiReceiverQueue(t *testing.T) { diff --git a/ds/queue/queue_test.go b/ds/queue/queue_test.go index bd93120..c3435ad 100644 --- a/ds/queue/queue_test.go +++ b/ds/queue/queue_test.go @@ -4,7 +4,7 @@ import ( "testing" "github.com/smartystreets/goconvey/convey" - "go.tempura.ink/co/ds/queue" + "github.com/tempurai/co/ds/queue" ) func TestQueue(t *testing.T) { diff --git a/from_chan.go b/from_chan.go index 8c87c12..86d0af3 100644 --- a/from_chan.go +++ b/from_chan.go @@ -1,7 +1,7 @@ package co import ( - syncx "go.tempura.ink/co/internal/syncx" + syncx "github.com/tempurai/co/internal/syncx" ) type AsyncChannel[R any] struct { diff --git a/from_chan_buffered.go b/from_chan_buffered.go index 9284574..ed00a9e 100644 --- a/from_chan_buffered.go +++ b/from_chan_buffered.go @@ -3,8 +3,8 @@ package co import ( "sync" - "go.tempura.ink/co/ds/queue" - syncx "go.tempura.ink/co/internal/syncx" + "github.com/tempurai/co/ds/queue" + syncx "github.com/tempurai/co/internal/syncx" ) type AsyncBufferedChan[R any] struct { diff --git a/from_chan_buffered_test.go b/from_chan_buffered_test.go index 2882546..3cc9d32 100644 --- a/from_chan_buffered_test.go +++ b/from_chan_buffered_test.go @@ -4,7 +4,7 @@ import ( "testing" "github.com/smartystreets/goconvey/convey" - "go.tempura.ink/co" + "github.com/tempurai/co" ) func TestAsyncBufferedChan(t *testing.T) { diff --git a/from_chan_test.go b/from_chan_test.go index b478f3a..d7abf24 100644 --- a/from_chan_test.go +++ b/from_chan_test.go @@ -5,7 +5,7 @@ import ( "time" "github.com/smartystreets/goconvey/convey" - "go.tempura.ink/co" + "github.com/tempurai/co" ) func TestAsyncChannel(t *testing.T) { diff --git a/from_fn.go b/from_fn.go index d8e4b92..71c2e0c 100644 --- a/from_fn.go +++ b/from_fn.go @@ -1,8 +1,8 @@ package co import ( - "go.tempura.ink/co/ds/queue" - syncx "go.tempura.ink/co/internal/syncx" + "github.com/tempurai/co/ds/queue" + syncx "github.com/tempurai/co/internal/syncx" ) type asyncFn[R any] func() (R, error) diff --git a/go.mod b/go.mod index 83955f0..85cc0a5 100755 --- a/go.mod +++ b/go.mod @@ -1,10 +1,11 @@ -module go.tempura.ink/co +module github.com/tempurai/co -go 1.18 +go 1.22 + +toolchain go1.22.0 require ( github.com/smartystreets/goconvey v1.7.2 - golang.org/x/exp v0.0.0-20220328175248-053ad81199eb ) require ( diff --git a/go.sum b/go.sum index 071d229..234fe39 100755 --- a/go.sum +++ b/go.sum @@ -1,5 +1,3 @@ -github.com/Jeffail/tunny v0.1.4 h1:chtpdz+nUtaYQeCKlNBg6GycFF/kGVHOr6A3cmzTJXs= -github.com/Jeffail/tunny v0.1.4/go.mod h1:P8xAx4XQl0xsuhjX1DtfaMDCSuavzdb2rwbd0lk+fvo= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo= @@ -9,8 +7,6 @@ github.com/smartystreets/assertions v1.2.0/go.mod h1:tcbTF8ujkAEcZ8TElKY+i30BzYl github.com/smartystreets/goconvey v1.7.2 h1:9RBaZCeXEQ3UselpuwUQHltGVXvdwm6cv1hgR6gDIPg= github.com/smartystreets/goconvey v1.7.2/go.mod h1:Vw0tHAZW6lzCRk3xgdin6fKYcG+G3Pg9vgXWeJpQFMM= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/exp v0.0.0-20220328175248-053ad81199eb h1:pC9Okm6BVmxEw76PUu0XUbOTQ92JX11hfvqTjAV3qxM= -golang.org/x/exp v0.0.0-20220328175248-053ad81199eb/go.mod h1:lgLbSvA5ygNOMpwM/9anMpWVlVJ7Z+cHWq/eFuinpGE= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= diff --git a/interval.go b/interval.go index 7ed7b3c..18cf6bb 100644 --- a/interval.go +++ b/interval.go @@ -3,7 +3,7 @@ package co import ( "time" - syncx "go.tempura.ink/co/internal/syncx" + syncx "github.com/tempurai/co/internal/syncx" ) type AsyncInterval[R any] struct { diff --git a/interval_test.go b/interval_test.go index d5f3b34..332ffa2 100644 --- a/interval_test.go +++ b/interval_test.go @@ -5,7 +5,7 @@ import ( "time" "github.com/smartystreets/goconvey/convey" - "go.tempura.ink/co" + "github.com/tempurai/co" ) func TestAsyncInterval(t *testing.T) { diff --git a/of_list_test.go b/of_list_test.go index ed3643a..1158f77 100644 --- a/of_list_test.go +++ b/of_list_test.go @@ -4,7 +4,7 @@ import ( "testing" "github.com/smartystreets/goconvey/convey" - "go.tempura.ink/co" + "github.com/tempurai/co" ) func TestAsyncList(t *testing.T) { diff --git a/parallel.go b/parallel.go index f5b07f4..a459b1a 100755 --- a/parallel.go +++ b/parallel.go @@ -4,8 +4,8 @@ import ( "sync" "sync/atomic" - "go.tempura.ink/co/ds/pool" - syncx "go.tempura.ink/co/internal/syncx" + "github.com/tempurai/co/ds/pool" + syncx "github.com/tempurai/co/internal/syncx" ) type parallel[R any] struct { diff --git a/parallel_test.go b/parallel_test.go index 631565c..13f1668 100755 --- a/parallel_test.go +++ b/parallel_test.go @@ -5,7 +5,7 @@ import ( "time" "github.com/smartystreets/goconvey/convey" - "go.tempura.ink/co" + "github.com/tempurai/co" ) func TestParallel(t *testing.T) { diff --git a/utils.go b/utils.go index 36f3ebc..1adf69a 100644 --- a/utils.go +++ b/utils.go @@ -1,8 +1,11 @@ package co -import ( - "golang.org/x/exp/constraints" -) +type Ordered interface { + ~int | ~int8 | ~int16 | ~int32 | ~int64 | + ~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr | + ~float32 | ~float64 | + ~string +} func Copy[T any](v *T) *T { v2 := *v @@ -16,7 +19,7 @@ func CastOrNil[T any](el any) T { return el.(T) } -func EvertGET[T constraints.Ordered](ele []T, target T) bool { +func EvertGET[T Ordered](ele []T, target T) bool { for _, e := range ele { if e <= target { return false