Skip to content

Commit 25cb915

Browse files
authored
feat: add goleak, guard InitRollbar on empty token (#29)
* feat: add goleak test coverage, guard InitRollbar on empty token - Add goleak.VerifyTestMain to catch goroutine leaks in tests - Guard InitRollbar with early return when token is empty, preventing rollbarInited=true with no token configured * fix: reset rollbarInited on empty token, bump Go to 1.25.9 Address review: set rollbarInited=false before early return so re-calling InitRollbar("", env) properly disables Rollbar after a previous init.
1 parent 9a99787 commit 25cb915

3 files changed

Lines changed: 17 additions & 1 deletion

File tree

go.mod

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/go-coldbrew/errors
22

3-
go 1.25.8
3+
go 1.25.9
44

55
require (
66
github.com/airbrake/gobrake/v5 v5.6.2
@@ -12,6 +12,7 @@ require (
1212
go.opentelemetry.io/otel v1.43.0
1313
go.opentelemetry.io/otel/sdk v1.43.0
1414
go.opentelemetry.io/otel/trace v1.43.0
15+
go.uber.org/goleak v1.3.0
1516
google.golang.org/grpc v1.79.3
1617
)
1718

goleak_test.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package errors
2+
3+
import (
4+
"testing"
5+
6+
"go.uber.org/goleak"
7+
)
8+
9+
func TestMain(m *testing.M) {
10+
goleak.VerifyTestMain(m)
11+
}

notifier/notifier.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,10 @@ func InitAirbrake(projectID int64, projectKey string) {
133133
// token: rollbar token
134134
// env: rollbar environment
135135
func InitRollbar(token, env string) {
136+
if token == "" {
137+
rollbarInited = false
138+
return
139+
}
136140
rollbar.SetToken(token)
137141
rollbar.SetEnvironment(env)
138142
rollbar.SetStackTracer(func(err error) ([]runtime.Frame, bool) {

0 commit comments

Comments
 (0)