From 03e1d76e2ce1f4cc7779844e6246ac1e82d1a1fe Mon Sep 17 00:00:00 2001 From: Tetsuya Morimoto Date: Sun, 4 Jun 2023 11:51:21 +0900 Subject: [PATCH] refactor: returns receive-only channel to prevent closing it from the caller #319 --- search.go | 2 +- v3/search.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/search.go b/search.go index 11bed706..cc2c1efd 100644 --- a/search.go +++ b/search.go @@ -587,7 +587,7 @@ func (l *Conn) Search(searchRequest *SearchRequest) (*SearchResult, error) { // all results until an error happens (or the search successfully finished), // e.g. for size / time limited requests all are recieved via the channel // until the limit is reached. -func (l *Conn) SearchWithChannel(ctx context.Context, searchRequest *SearchRequest) chan *SearchSingleResult { +func (l *Conn) SearchWithChannel(ctx context.Context, searchRequest *SearchRequest) <-chan *SearchSingleResult { ch := make(chan *SearchSingleResult) go func() { defer close(ch) diff --git a/v3/search.go b/v3/search.go index 334ad6e0..ae8b837b 100644 --- a/v3/search.go +++ b/v3/search.go @@ -589,7 +589,7 @@ func (l *Conn) Search(searchRequest *SearchRequest) (*SearchResult, error) { // all results until an error happens (or the search successfully finished), // e.g. for size / time limited requests all are recieved via the channel // until the limit is reached. -func (l *Conn) SearchWithChannel(ctx context.Context, searchRequest *SearchRequest) chan *SearchSingleResult { +func (l *Conn) SearchWithChannel(ctx context.Context, searchRequest *SearchRequest) <-chan *SearchSingleResult { ch := make(chan *SearchSingleResult) go func() { defer close(ch)