Skip to content

Commit

Permalink
refactor: change channel types in Head and Tail functions to use rece…
Browse files Browse the repository at this point in the history
…ive-only channels
  • Loading branch information
WangYihang committed Apr 11, 2024
1 parent 85b4341 commit 15e9534
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pkg/utils/io.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
)

// Head takes a channel and returns a channel with the first n items
func Head[T interface{}](in chan T, max int) chan T {
func Head[T interface{}](in <-chan T, max int) <-chan T {
out := make(chan T)
go func() {
defer close(out)
Expand All @@ -25,7 +25,7 @@ func Head[T interface{}](in chan T, max int) chan T {
}

// Tail takes a channel and returns a channel with the last n items
func Tail[T interface{}](in chan T, max int) chan T {
func Tail[T interface{}](in <-chan T, max int) <-chan T {
out := make(chan T)
go func() {
defer close(out)
Expand Down

0 comments on commit 15e9534

Please sign in to comment.