Skip to content

Commit 6609549

Browse files
committed
Merge remote-tracking branch 'origin/main'
# Conflicts: # README.md
2 parents 9a982b6 + 79aedd6 commit 6609549

File tree

5 files changed

+41
-6
lines changed

5 files changed

+41
-6
lines changed

.github/dependabot.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
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

.github/workflows/lint.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ jobs:
1010
runs-on: ubuntu-latest
1111

1212
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
1517
- uses: golangci/golangci-lint-action@v3

.github/workflows/test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ jobs:
1515
runs-on: ${{ matrix.platform }}
1616

1717
steps:
18-
- uses: actions/checkout@v3
19-
- uses: actions/setup-go@v3
18+
- uses: actions/checkout@v4
19+
- uses: actions/setup-go@v5
2020
with:
2121
go-version: ${{ matrix.go-version }}
2222

README.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,30 +7,41 @@ writing
77
[![Documentation][doc-img]][doc-url]
88

99
[latest-release-img]: https://img.shields.io/github/release/go-pogo/writing.svg?label=latest
10+
1011
[latest-release-url]: https://github.com/go-pogo/writing/releases
12+
1113
[build-status-img]: https://github.com/go-pogo/writing/workflows/Test/badge.svg
14+
1215
[build-status-url]: https://github.com/go-pogo/writing/actions/workflows/test.yml
16+
1317
[report-img]: https://goreportcard.com/badge/github.com/go-pogo/writing
18+
1419
[report-url]: https://goreportcard.com/report/github.com/go-pogo/writing
20+
1521
[doc-img]: https://godoc.org/github.com/go-pogo/writing?status.svg
22+
1623
[doc-url]: https://pkg.go.dev/github.com/go-pogo/writing
1724

1825
Package `writing`.
1926

2027
```sh
2128
go get github.com/go-pogo/writing
2229
```
30+
2331
```go
2432
import "github.com/go-pogo/writing"
2533
```
2634

2735
## Documentation
36+
2837
Additional detailed documentation is available at [pkg.go.dev][doc-url]
2938

3039
## Created with
40+
3141
<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>
3242

3343
## 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.
3546

3647
This project is governed by a BSD-style license that can be found in the [LICENSE](LICENSE) file.

bytes.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,32 @@ import (
99
"sync"
1010
)
1111

12+
// A BytesBufferPool is a sync.Pool which stores bytes.Buffer(s).
1213
type BytesBufferPool struct {
1314
p sync.Pool
1415
}
1516

17+
// NewBytesBufferPool creates a new BytesBufferPool with a given initial
18+
// capacity n for each retrieved bytes.Buffer.
1619
func NewBytesBufferPool(n int) *BytesBufferPool {
1720
return &BytesBufferPool{p: sync.Pool{
1821
New: func() interface{} {
1922
var buf bytes.Buffer
20-
buf.Grow(n)
23+
if n != 0 {
24+
buf.Grow(n)
25+
}
2126
return &buf
2227
},
2328
}}
2429
}
2530

31+
// Get selects an arbitrary bytes.Buffer from the BytesBufferPool, removes it
32+
// from the pool, and returns it to the caller.
2633
func (p *BytesBufferPool) Get() *bytes.Buffer {
2734
return p.p.Get().(*bytes.Buffer)
2835
}
2936

37+
// Put adds the bytes.Buffer b to the pool.
3038
func (p *BytesBufferPool) Put(b *bytes.Buffer) {
3139
b.Reset()
3240
p.p.Put(b)

0 commit comments

Comments
 (0)