From d13aa336fffc455da7bb18bffa87b7bfb39e17c8 Mon Sep 17 00:00:00 2001 From: chaoqiangc Date: Mon, 22 Dec 2025 14:06:47 +0800 Subject: [PATCH] fix(main): Avoid adding package list to nil module - Check if mod is nil before appending to mod.Pkgs - Prevent potential nil pointer dereference errors If the first line of modules.txt is a replace directive, for example: ```txt # dm v0.0.0 => ../db/drivers/dm/8.1.4.80/dm ``` In this case, the variable mod may not be initialized, causing a nil pointer error. Therefore, check if mod is nil before appending to avoid this issue. --- main.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index c21bb64..4492b29 100644 --- a/main.go +++ b/main.go @@ -127,7 +127,9 @@ func main() { continue } - mod.Pkgs = append(mod.Pkgs, line) + if mod != nil { + mod.Pkgs = append(mod.Pkgs, line) + } } // Filter out files not part of the mod.Pkgs