Skip to content

Commit 7d9aa41

Browse files
committed
review fixes: GoDoc comments + CI updates
1 parent 5341e34 commit 7d9aa41

File tree

5 files changed

+30
-10
lines changed

5 files changed

+30
-10
lines changed

.github/workflows/testing.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,17 @@ jobs:
2929

3030
- name: Run tests with race-detector
3131
run: make test-race
32+
33+
golangci-lint:
34+
runs-on: ubuntu-24.04
35+
steps:
36+
- uses: actions/setup-go@v5
37+
- uses: actions/checkout@v5
38+
39+
- name: Install golangci-lint
40+
uses: golangci/golangci-lint-action@v3
41+
with:
42+
version: latest
43+
44+
- name: Run linter
45+
run: make lint

LICENCE

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,8 @@ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
2222
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
2323
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
2424
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25-
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26+
27+
Portions of this software are derived from the Go standard library,
28+
Copyright (c) The Go Authors,
29+
and are used under the terms of the BSD-style license.

Makefile

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ GO ?= go
33
GOLANGCI_LINT ?= golangci-lint
44
PKG := github.com/tarantool/go-tlog
55

6-
.PHONY: all test test-race test-coverage lint fmt tidy examples help
6+
.PHONY: all test test-race test-coverage lint fmt tidy help
77

88
all: test
99

@@ -31,13 +31,6 @@ fmt:
3131
tidy:
3232
$(GO) mod tidy
3333

34-
## Run all _examples to ensure they compile and run without panic.
35-
examples:
36-
$(GO) run ./_examples/stdout
37-
$(GO) run ./_examples/stderr >/dev/null 2>&1 || true
38-
$(GO) run ./_examples/file
39-
$(GO) run ./_examples/multi
40-
4134
## Show available targets.
4235
help:
4336
@echo "Available targets:"
@@ -47,4 +40,3 @@ help:
4740
@echo " make lint - run golangci-lint"
4841
@echo " make fmt - format sources (gofmt)"
4942
@echo " make tidy - go mod tidy"
50-
@echo " make examples - run all examples"

internal/outputs/outputs.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ func multiClose(files []*os.File) error {
9292
return errors.Join(errs...)
9393
}
9494

95+
// Write writes p to all configured output destinations.
96+
// It implements io.Writer and is used by slog handlers.
9597
func (o *Outputs) Write(p []byte) (int, error) {
9698
return o.w.Write(p)
9799
}

internal/slog/buffer.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ func newBuffer() *buffer {
2525
return bufPool.Get().(*buffer)
2626
}
2727

28+
// Free releases the buffer back to the pool.
2829
func (b *buffer) Free() {
2930
// To reduce peak allocation, return only smaller buffers to the pool.
3031
const maxBufferSize = 16 << 10
@@ -34,33 +35,40 @@ func (b *buffer) Free() {
3435
}
3536
}
3637

38+
// Reset clears the buffer contents by setting its length to zero.
3739
func (b *buffer) Reset() {
3840
b.SetLen(0)
3941
}
4042

43+
// Write appends the provided bytes to the buffer.
4144
func (b *buffer) Write(p []byte) (int, error) {
4245
*b = append(*b, p...)
4346
return len(p), nil
4447
}
4548

49+
// WriteString appends the provided string to the buffer.
4650
func (b *buffer) WriteString(s string) (int, error) {
4751
*b = append(*b, s...)
4852
return len(s), nil
4953
}
5054

55+
// WriteByte appends a single byte to the buffer.
5156
func (b *buffer) WriteByte(c byte) error {
5257
*b = append(*b, c)
5358
return nil
5459
}
5560

61+
// String returns the contents of the buffer as a string.
5662
func (b *buffer) String() string {
5763
return string(*b)
5864
}
5965

66+
// Len returns the number of bytes currently stored in the buffer.
6067
func (b *buffer) Len() int {
6168
return len(*b)
6269
}
6370

71+
// SetLen reslices the buffer to the specified length.
6472
func (b *buffer) SetLen(n int) {
6573
*b = (*b)[:n]
6674
}

0 commit comments

Comments
 (0)