INNER CODE UNIT · Go
getGoModules
alibaba/loongcollector · tools/builder/main.go:243
func getGoModules(ctx *buildContext) error {
cmd := exec.Command(ctx.GoExe, "mod", "tidy", "-modfile", ctx.ModFile)
cmd.Dir = ctx.ProjectRoot
out, err := cmd.CombinedOutput()
if err != nil {
return fmt.Errorf("failed to execute go mod tidy, err: %w, output: %s", err, out)
}
cmd = exec.Command(ctx.GoExe, "mod", "download", "-modfile", ctx.ModFile)
cmd.Dir = ctx.ProjectRoot
out, err = cmd.CombinedOutput()
if err != nil {
return fmt.Errorf("failed to download go modules, err: %w, output: %s", err, out)
}
path := getAbsPath(ctx.ModFile, ctx.ProjectRoot)
mods, err := os.ReadFile(path) // nolint
if err != nil {