Skip to content

Commit

Permalink
cmd/gonew: remove redundant parameter srcMod
Browse files Browse the repository at this point in the history
Running AddModuleStmt to a Module will create/update the path to
dstMod and ignore the srcMod if exists. So we do not need srcMod.
  • Loading branch information
oseau committed Apr 23, 2024
1 parent 97ea816 commit d49cbec
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions cmd/gonew/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit d49cbec

Please sign in to comment.