From 01cd58cba4e5c83c3bc145d0a33de31dfb12c30c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89mile=20R=C3=A9?= Date: Fri, 12 Jun 2026 12:48:39 +0200 Subject: [PATCH] Rename strutil to stringsx, use wg.Go MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Address PR review feedback: rename the shared string-helper package from strutil to stringsx to avoid the discouraged util suffix and the collision with the standard strings package, updating all import paths and call sites. Replace the manual wg.Add/wg.Done bookkeeping in the enrichment worker with wg.Go, which is less error-prone. Signed-off-by: Émile Ré --- pkg/cookiebanner/tracker_mapping_worker.go | 12 +++++------ .../strutil.go => stringsx/stringsx.go} | 4 ++-- .../stringsx_test.go} | 6 +++--- .../common_third_party_enrichment_worker.go | 20 ++++++------------- .../common_third_party_owned_domains.go | 4 ++-- 5 files changed, 19 insertions(+), 27 deletions(-) rename pkg/{strutil/strutil.go => stringsx/stringsx.go} (93%) rename pkg/{strutil/strutil_test.go => stringsx/stringsx_test.go} (91%) diff --git a/pkg/cookiebanner/tracker_mapping_worker.go b/pkg/cookiebanner/tracker_mapping_worker.go index 079a5c340..1052335d3 100644 --- a/pkg/cookiebanner/tracker_mapping_worker.go +++ b/pkg/cookiebanner/tracker_mapping_worker.go @@ -28,7 +28,7 @@ import ( "go.probo.inc/probo/pkg/coredata" "go.probo.inc/probo/pkg/gid" "go.probo.inc/probo/pkg/llm" - "go.probo.inc/probo/pkg/strutil" + "go.probo.inc/probo/pkg/stringsx" "go.probo.inc/probo/pkg/thirdparty" "go.probo.inc/probo/pkg/uri" ) @@ -716,15 +716,15 @@ func nameMatchesSiteDomain(name, siteOrigin string) bool { return false } - normalizedName := strutil.NormalizeAlnum(name) + normalizedName := stringsx.NormalizeAlnum(name) if normalizedName == "" { return false } label, _, _ := strings.Cut(domain, ".") - return normalizedName == strutil.NormalizeAlnum(domain) || - normalizedName == strutil.NormalizeAlnum(label) + return normalizedName == stringsx.NormalizeAlnum(domain) || + normalizedName == stringsx.NormalizeAlnum(label) } // cookieDatabaseAggregators holds alphanumeric-normalised names of pure @@ -754,11 +754,11 @@ var cookieDatabaseAggregators = map[string]struct{}{ // normalised so spacing, punctuation, and casing differences do not // matter. func nameIsCookieDatabaseAggregator(name string) bool { - if _, ok := cookieDatabaseAggregators[strutil.NormalizeAlnum(name)]; ok { + if _, ok := cookieDatabaseAggregators[stringsx.NormalizeAlnum(name)]; ok { return true } - label := strutil.NormalizeAlnum(uri.DomainLabel(name)) + label := stringsx.NormalizeAlnum(uri.DomainLabel(name)) if label == "" { return false } diff --git a/pkg/strutil/strutil.go b/pkg/stringsx/stringsx.go similarity index 93% rename from pkg/strutil/strutil.go rename to pkg/stringsx/stringsx.go index a42adcec5..9787c4387 100644 --- a/pkg/strutil/strutil.go +++ b/pkg/stringsx/stringsx.go @@ -12,9 +12,9 @@ // OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR // PERFORMANCE OF THIS SOFTWARE. -// Package strutil holds small, dependency-free string helpers shared +// Package stringsx holds small, dependency-free string helpers shared // across packages. -package strutil +package stringsx import "strings" diff --git a/pkg/strutil/strutil_test.go b/pkg/stringsx/stringsx_test.go similarity index 91% rename from pkg/strutil/strutil_test.go rename to pkg/stringsx/stringsx_test.go index ff812f97c..838216498 100644 --- a/pkg/strutil/strutil_test.go +++ b/pkg/stringsx/stringsx_test.go @@ -12,13 +12,13 @@ // OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR // PERFORMANCE OF THIS SOFTWARE. -package strutil_test +package stringsx_test import ( "testing" "github.com/stretchr/testify/assert" - "go.probo.inc/probo/pkg/strutil" + "go.probo.inc/probo/pkg/stringsx" ) func TestNormalizeAlnum(t *testing.T) { @@ -41,7 +41,7 @@ func TestNormalizeAlnum(t *testing.T) { tt.name, func(t *testing.T) { t.Parallel() - assert.Equal(t, tt.expected, strutil.NormalizeAlnum(tt.input)) + assert.Equal(t, tt.expected, stringsx.NormalizeAlnum(tt.input)) }, ) } diff --git a/pkg/thirdparty/common_third_party_enrichment_worker.go b/pkg/thirdparty/common_third_party_enrichment_worker.go index e9dcd49b0..25eedceb4 100644 --- a/pkg/thirdparty/common_third_party_enrichment_worker.go +++ b/pkg/thirdparty/common_third_party_enrichment_worker.go @@ -299,25 +299,17 @@ func (h *enrichmentHandler) Process(ctx context.Context, party coredata.CommonTh var wg sync.WaitGroup - wg.Add(3) - - go func() { - defer wg.Done() - + wg.Go(func() { compliance, complianceErr = h.runComplianceDocs(ctx, party.Name, website, legalName) - }() - - go func() { - defer wg.Done() + }) + wg.Go(func() { domainsResult, domainsErr = h.runDomains(ctx, party.Name, website) - }() - - go func() { - defer wg.Done() + }) + wg.Go(func() { logoFile = h.prepareLogo(ctx, party, website) - }() + }) wg.Wait() diff --git a/pkg/thirdparty/common_third_party_owned_domains.go b/pkg/thirdparty/common_third_party_owned_domains.go index ca78fd53d..39ec42305 100644 --- a/pkg/thirdparty/common_third_party_owned_domains.go +++ b/pkg/thirdparty/common_third_party_owned_domains.go @@ -18,7 +18,7 @@ import ( "slices" "strings" - "go.probo.inc/probo/pkg/strutil" + "go.probo.inc/probo/pkg/stringsx" "go.probo.inc/probo/pkg/uri" ) @@ -158,7 +158,7 @@ func vendorLabels(name, website string) []string { } add(uri.DomainLabel(website)) - add(strutil.NormalizeAlnum(name)) + add(stringsx.NormalizeAlnum(name)) return labels }