Skip to content

Commit

Permalink
chore(internal/postprocessor): ensure new modules are added to worksp…
Browse files Browse the repository at this point in the history
…ace (#8013)
  • Loading branch information
codyoss authored May 30, 2023
1 parent 71b1326 commit 23cf597
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
7 changes: 7 additions & 0 deletions internal/postprocessor/execv/gocmd/gocmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,3 +138,10 @@ func EditReplace(dir, mod, modPath string) error {
}
return c.Run()
}

// WorkUse updates the go.work file for added modules.
func WorkUse(dir string) error {
c := execv.Command("go", "work", "use", "-r", ".")
c.Dir = dir
return c.Run()
}
6 changes: 5 additions & 1 deletion internal/postprocessor/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,11 @@ func (p *postProcessor) generateModule(modPath, importPath string) error {
return err
}
log.Printf("Creating %s/go.mod", modPath)
return gocmd.ModInit(modPath, importPath)
if err := gocmd.ModInit(modPath, importPath); err != nil {
return err
}
log.Print("Updating workspace")
return gocmd.WorkUse(p.googleCloudDir)
}

func (p *postProcessor) generateVersionFile(moduleName, path string) error {
Expand Down

0 comments on commit 23cf597

Please sign in to comment.