File tree Expand file tree Collapse file tree 5 files changed +41
-6
lines changed Expand file tree Collapse file tree 5 files changed +41
-6
lines changed Original file line number Diff line number Diff line change
1
+ version : 2
2
+ updates :
3
+ - package-ecosystem : " gomod"
4
+ directory : " /"
5
+ schedule :
6
+ interval : " daily"
7
+ open-pull-requests-limit : 2
8
+
9
+ - package-ecosystem : " github-actions"
10
+ directory : " /"
11
+ schedule :
12
+ interval : " weekly"
13
+ day : " thursday"
14
+ open-pull-requests-limit : 2
Original file line number Diff line number Diff line change 10
10
runs-on : ubuntu-latest
11
11
12
12
steps :
13
- - uses : actions/checkout@v3
14
- - uses : actions/setup-go@v3
13
+ - uses : actions/checkout@v4
14
+ - uses : actions/setup-go@v5
15
+ with :
16
+ go-version : stable
15
17
- uses : golangci/golangci-lint-action@v3
Original file line number Diff line number Diff line change 15
15
runs-on : ${{ matrix.platform }}
16
16
17
17
steps :
18
- - uses : actions/checkout@v3
19
- - uses : actions/setup-go@v3
18
+ - uses : actions/checkout@v4
19
+ - uses : actions/setup-go@v5
20
20
with :
21
21
go-version : ${{ matrix.go-version }}
22
22
Original file line number Diff line number Diff line change @@ -7,30 +7,41 @@ writing
7
7
[ ![ Documentation] [ doc-img ]] [ doc-url ]
8
8
9
9
[ latest-release-img ] : https://img.shields.io/github/release/go-pogo/writing.svg?label=latest
10
+
10
11
[ latest-release-url ] : https://github.com/go-pogo/writing/releases
12
+
11
13
[ build-status-img ] : https://github.com/go-pogo/writing/workflows/Test/badge.svg
14
+
12
15
[ build-status-url ] : https://github.com/go-pogo/writing/actions/workflows/test.yml
16
+
13
17
[ report-img ] : https://goreportcard.com/badge/github.com/go-pogo/writing
18
+
14
19
[ report-url ] : https://goreportcard.com/report/github.com/go-pogo/writing
20
+
15
21
[ doc-img ] : https://godoc.org/github.com/go-pogo/writing?status.svg
22
+
16
23
[ doc-url ] : https://pkg.go.dev/github.com/go-pogo/writing
17
24
18
25
Package ` writing ` .
19
26
20
27
``` sh
21
28
go get github.com/go-pogo/writing
22
29
```
30
+
23
31
``` go
24
32
import " github.com/go-pogo/writing"
25
33
```
26
34
27
35
## Documentation
36
+
28
37
Additional detailed documentation is available at [ pkg.go.dev] [ doc-url ]
29
38
30
39
## Created with
40
+
31
41
<a href =" https://www.jetbrains.com/?from=go-pogo " target =" _blank " ><img src =" https://resources.jetbrains.com/storage/products/company/brand/logos/GoLand_icon.png " width =" 35 " /></a >
32
42
33
43
## License
34
- Copyright © 2022-2023 [ Roel Schut] ( https://roelschut.nl ) . All rights reserved.
44
+
45
+ Copyright © 2022-2024 [ Roel Schut] ( https://roelschut.nl ) . All rights reserved.
35
46
36
47
This project is governed by a BSD-style license that can be found in the [ LICENSE] ( LICENSE ) file.
Original file line number Diff line number Diff line change @@ -9,24 +9,32 @@ import (
9
9
"sync"
10
10
)
11
11
12
+ // A BytesBufferPool is a sync.Pool which stores bytes.Buffer(s).
12
13
type BytesBufferPool struct {
13
14
p sync.Pool
14
15
}
15
16
17
+ // NewBytesBufferPool creates a new BytesBufferPool with a given initial
18
+ // capacity n for each retrieved bytes.Buffer.
16
19
func NewBytesBufferPool (n int ) * BytesBufferPool {
17
20
return & BytesBufferPool {p : sync.Pool {
18
21
New : func () interface {} {
19
22
var buf bytes.Buffer
20
- buf .Grow (n )
23
+ if n != 0 {
24
+ buf .Grow (n )
25
+ }
21
26
return & buf
22
27
},
23
28
}}
24
29
}
25
30
31
+ // Get selects an arbitrary bytes.Buffer from the BytesBufferPool, removes it
32
+ // from the pool, and returns it to the caller.
26
33
func (p * BytesBufferPool ) Get () * bytes.Buffer {
27
34
return p .p .Get ().(* bytes.Buffer )
28
35
}
29
36
37
+ // Put adds the bytes.Buffer b to the pool.
30
38
func (p * BytesBufferPool ) Put (b * bytes.Buffer ) {
31
39
b .Reset ()
32
40
p .p .Put (b )
You can’t perform that action at this time.
0 commit comments