From cb2eb1097a511fe5ef5f4549a3b56078c2382ead Mon Sep 17 00:00:00 2001 From: Tw93 Date: Sat, 14 Mar 2026 07:46:32 +0800 Subject: [PATCH] fix(analyze): add darwin build tag to all platform-specific files All files in cmd/analyze/ are macOS-only but several were missing the //go:build darwin constraint. On Linux (e.g. CodeQL CI), Go compiled these files without the types defined in main.go (which had the tag), causing undefined symbol errors for dirEntry, fileEntry, scanResult, cacheEntry, historyEntry and model. - Add //go:build darwin to heap.go, cache.go, scanner.go, cleanable.go, delete.go, format.go, constants.go and all *_test.go files Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- cmd/analyze/analyze_test.go | 2 ++ cmd/analyze/cache.go | 2 ++ cmd/analyze/cleanable.go | 2 ++ cmd/analyze/constants.go | 2 ++ cmd/analyze/delete.go | 2 ++ cmd/analyze/delete_test.go | 2 ++ cmd/analyze/format.go | 2 ++ cmd/analyze/format_test.go | 4 +++- cmd/analyze/heap.go | 2 ++ cmd/analyze/heap_test.go | 2 ++ cmd/analyze/main_stub.go | 13 +++++++++++++ cmd/analyze/scanner.go | 2 ++ cmd/analyze/scanner_test.go | 2 ++ cmd/analyze/test_helpers_test.go | 2 ++ 14 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 cmd/analyze/main_stub.go diff --git a/cmd/analyze/analyze_test.go b/cmd/analyze/analyze_test.go index 7a2fecd..7b0390e 100644 --- a/cmd/analyze/analyze_test.go +++ b/cmd/analyze/analyze_test.go @@ -1,3 +1,5 @@ +//go:build darwin + package main import ( diff --git a/cmd/analyze/cache.go b/cmd/analyze/cache.go index 872a8d5..1b19ea6 100644 --- a/cmd/analyze/cache.go +++ b/cmd/analyze/cache.go @@ -1,3 +1,5 @@ +//go:build darwin + package main import ( diff --git a/cmd/analyze/cleanable.go b/cmd/analyze/cleanable.go index 4c80879..5a7f8c5 100644 --- a/cmd/analyze/cleanable.go +++ b/cmd/analyze/cleanable.go @@ -1,3 +1,5 @@ +//go:build darwin + package main import ( diff --git a/cmd/analyze/constants.go b/cmd/analyze/constants.go index d400035..abb46d4 100644 --- a/cmd/analyze/constants.go +++ b/cmd/analyze/constants.go @@ -1,3 +1,5 @@ +//go:build darwin + package main import "time" diff --git a/cmd/analyze/delete.go b/cmd/analyze/delete.go index 11feaee..196d751 100644 --- a/cmd/analyze/delete.go +++ b/cmd/analyze/delete.go @@ -1,3 +1,5 @@ +//go:build darwin + package main import ( diff --git a/cmd/analyze/delete_test.go b/cmd/analyze/delete_test.go index 8d89ae1..af95431 100644 --- a/cmd/analyze/delete_test.go +++ b/cmd/analyze/delete_test.go @@ -1,3 +1,5 @@ +//go:build darwin + package main import ( diff --git a/cmd/analyze/format.go b/cmd/analyze/format.go index 371539b..26d589e 100644 --- a/cmd/analyze/format.go +++ b/cmd/analyze/format.go @@ -1,3 +1,5 @@ +//go:build darwin + package main import ( diff --git a/cmd/analyze/format_test.go b/cmd/analyze/format_test.go index 65a8333..96241f3 100644 --- a/cmd/analyze/format_test.go +++ b/cmd/analyze/format_test.go @@ -1,3 +1,5 @@ +//go:build darwin + package main import ( @@ -20,7 +22,7 @@ func TestRuneWidth(t *testing.T) { {"CJK ideograph", '語', 2}, {"Full-width number", '1', 2}, {"ASCII space", ' ', 1}, - {"Tab", '\t', 1}, + {"Tab", ' ', 1}, } for _, tt := range tests { diff --git a/cmd/analyze/heap.go b/cmd/analyze/heap.go index 0b4a5a5..919ad1a 100644 --- a/cmd/analyze/heap.go +++ b/cmd/analyze/heap.go @@ -1,3 +1,5 @@ +//go:build darwin + package main // entryHeap is a min-heap of dirEntry used to keep Top N largest entries. diff --git a/cmd/analyze/heap_test.go b/cmd/analyze/heap_test.go index 77408fc..12a1341 100644 --- a/cmd/analyze/heap_test.go +++ b/cmd/analyze/heap_test.go @@ -1,3 +1,5 @@ +//go:build darwin + package main import ( diff --git a/cmd/analyze/main_stub.go b/cmd/analyze/main_stub.go new file mode 100644 index 0000000..89bd0e0 --- /dev/null +++ b/cmd/analyze/main_stub.go @@ -0,0 +1,13 @@ +//go:build !darwin + +package main + +import ( + "fmt" + "os" +) + +func main() { + fmt.Fprintln(os.Stderr, "analyze is only supported on macOS") + os.Exit(1) +} diff --git a/cmd/analyze/scanner.go b/cmd/analyze/scanner.go index f22387b..eac8fda 100644 --- a/cmd/analyze/scanner.go +++ b/cmd/analyze/scanner.go @@ -1,3 +1,5 @@ +//go:build darwin + package main import ( diff --git a/cmd/analyze/scanner_test.go b/cmd/analyze/scanner_test.go index 718d276..c5a7557 100644 --- a/cmd/analyze/scanner_test.go +++ b/cmd/analyze/scanner_test.go @@ -1,3 +1,5 @@ +//go:build darwin + package main import ( diff --git a/cmd/analyze/test_helpers_test.go b/cmd/analyze/test_helpers_test.go index 9490833..a84fe1a 100644 --- a/cmd/analyze/test_helpers_test.go +++ b/cmd/analyze/test_helpers_test.go @@ -1,3 +1,5 @@ +//go:build darwin + package main import (