From 700889269f740f659c9f3867f2b79fed677b74b0 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Mon, 18 Nov 2024 07:51:43 -0300 Subject: [PATCH] fix: no output In the windows support efforts, accidentally started using testlib in production code. `testlib` disables log output on `init`, which was causing the issue. fixed the usage, and added a panic if `testlib` is used outside of tests. closes #5292 --- internal/http/http.go | 4 ++-- internal/testlib/log.go | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/internal/http/http.go b/internal/http/http.go index a36bc0f90..fcd532d2e 100644 --- a/internal/http/http.go +++ b/internal/http/http.go @@ -8,6 +8,7 @@ import ( "io" h "net/http" "os" + "runtime" "strings" "github.com/caarlos0/log" @@ -15,7 +16,6 @@ import ( "github.com/goreleaser/goreleaser/v2/internal/extrafiles" "github.com/goreleaser/goreleaser/v2/internal/pipe" "github.com/goreleaser/goreleaser/v2/internal/semerrgroup" - "github.com/goreleaser/goreleaser/v2/internal/testlib" "github.com/goreleaser/goreleaser/v2/internal/tmpl" "github.com/goreleaser/goreleaser/v2/pkg/config" "github.com/goreleaser/goreleaser/v2/pkg/context" @@ -336,7 +336,7 @@ func getHTTPClient(upload *config.Upload) (*h.Client, error) { if upload.TrustedCerts != "" { pool, err := x509.SystemCertPool() if err != nil { - if testlib.IsWindows() { + if runtime.GOOS == "windows" { // on windows ignore errors until golang issues #16736 & #18609 get fixed pool = x509.NewCertPool() } else { diff --git a/internal/testlib/log.go b/internal/testlib/log.go index 17c533a23..1ffdbaa58 100644 --- a/internal/testlib/log.go +++ b/internal/testlib/log.go @@ -2,10 +2,14 @@ package testlib import ( "io" + "testing" "github.com/caarlos0/log" ) func init() { + if !testing.Testing() { + log.Fatal("testlib should not be used in production code!") + } log.Log = log.New(io.Discard) }