From d49cbecf21b9a46bab41c74e7354926b3b2ef9d7 Mon Sep 17 00:00:00 2001 From: yang Date: Tue, 23 Apr 2024 20:10:02 +0800 Subject: [PATCH] cmd/gonew: remove redundant parameter srcMod Running AddModuleStmt to a Module will create/update the path to dstMod and ignore the srcMod if exists. So we do not need srcMod. --- cmd/gonew/main.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/gonew/main.go b/cmd/gonew/main.go index 920d56a1bf6..8830c8b512b 100644 --- a/cmd/gonew/main.go +++ b/cmd/gonew/main.go @@ -150,7 +150,7 @@ func main() { data = fixGo(data, rel, srcMod, dstMod, isRoot) } if rel == "go.mod" { - data = fixGoMod(data, srcMod, dstMod) + data = fixGoMod(data, dstMod) } if err := os.WriteFile(dst, data, 0666); err != nil { @@ -219,7 +219,7 @@ func fixGo(data []byte, file string, srcMod, dstMod string, isRoot bool) []byte // fixGoMod rewrites the go.mod content in data to replace srcMod with dstMod // in the module path. -func fixGoMod(data []byte, srcMod, dstMod string) []byte { +func fixGoMod(data []byte, dstMod string) []byte { f, err := modfile.ParseLax("go.mod", data, nil) if err != nil { log.Fatalf("parsing source module:\n%s", err)