Native Go output to the systemd journal socket.
Go to file
Laurence Withers d3666c9152 Fix slice gotchas including concurrency race
If the []Attr slice passed to Conn.Entry was used in several concurrent
calls, and it had sufficient capacity that append()ing to it succeeded
without reallocating the slice, then a data race would exist.

Fix this, and fix the efficiency gotcha which expected the attribute
slice to have additional capacity, by instead always constructing a new
final slice of []Attr and using a sync.Pool to avoid reallocating them.

Fixes go test -race, and improves the benchmark. Before:
	goos: linux
	goarch: amd64
	pkg: src.lwithers.me.uk/go/journal
	cpu: 11th Gen Intel(R) Core(TM) i5-1135G7 @ 2.40GHz
	BenchmarkEntry-8   	8345163	    2139 ns/op	   848 B/op	    15 allocs/op
	PASS
	ok  	src.lwithers.me.uk/go/journal	20.034s

After:
	goos: linux
	goarch: amd64
	pkg: src.lwithers.me.uk/go/journal
	cpu: 11th Gen Intel(R) Core(TM) i5-1135G7 @ 2.40GHz
	BenchmarkEntry-8   	12611158	    1445 ns/op	   221 B/op	     7 allocs/op
	PASS
	ok  	src.lwithers.me.uk/go/journal	19.673s
2024-02-18 14:43:33 +00:00
LICENSE Initial working version 2024-02-18 10:31:14 +00:00
README.md Initial commit 2024-02-17 10:19:21 +00:00
attr.go Initial working version 2024-02-18 10:31:14 +00:00
attr_key.go Initial working version 2024-02-18 10:31:14 +00:00
attr_key_test.go Initial working version 2024-02-18 10:31:14 +00:00
attr_test.go Initial working version 2024-02-18 10:31:14 +00:00
conn.go Fix slice gotchas including concurrency race 2024-02-18 14:43:33 +00:00
conn_test.go Add some higher level tests and benchmarks 2024-02-18 14:00:29 +00:00
global.go Initial working version 2024-02-18 10:31:14 +00:00
go.mod Initial working version 2024-02-18 10:31:14 +00:00
priority.go Initial working version 2024-02-18 10:31:14 +00:00
wire_proto.go Initial working version 2024-02-18 10:31:14 +00:00
wire_proto_test.go Initial working version 2024-02-18 10:31:14 +00:00

README.md

journal

Native Go output to the systemd journal socket.