From 94f7314157688c2a17434a032f062afc4e51a660 Mon Sep 17 00:00:00 2001 From: qydysky Date: Thu, 14 Dec 2023 22:50:15 +0800 Subject: [PATCH] 1 --- slice/Blocks.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/slice/Blocks.go b/slice/Blocks.go index 5de6c8a..b3a6752 100644 --- a/slice/Blocks.go +++ b/slice/Blocks.go @@ -4,7 +4,7 @@ import ( "errors" ) -type blocks[T any] struct { +type Blocks[T any] struct { free chan int size int buf []T @@ -12,8 +12,8 @@ type blocks[T any] struct { var ErrOverflow = errors.New("ErrOverflow") -func NewBlocks[T any](blockSize int, blockNum int) *blocks[T] { - p := &blocks[T]{ +func NewBlocks[T any](blockSize int, blockNum int) *Blocks[T] { + p := &Blocks[T]{ size: blockSize, free: make(chan int, blockNum+1), buf: make([]T, blockSize*blockNum), @@ -31,7 +31,7 @@ func NewBlocks[T any](blockSize int, blockNum int) *blocks[T] { // // do something with tmpbuf // putBack() // } -func (t *blocks[T]) Get() ([]T, func(), error) { +func (t *Blocks[T]) Get() ([]T, func(), error) { select { case offset := <-t.free: offset *= t.size -- 2.39.2