feat: try to remove toolchain first

main
sudo pacman -Syu 2024-11-01 19:05:29 +07:00
parent 7b72dd3746
commit f4593dcc61
1 changed files with 16 additions and 18 deletions

View File

@ -75,15 +75,6 @@ func (a *action) Run(c *cli.Context) error {
return err return err
} }
goMod, err := a.runReadGoMod()
if err != nil {
return err
}
if err := a.runVerifyGoMod(goMod); err != nil {
return err
}
if err := a.runGitCommit(c, successUpgradedModules, existVendor, useDepFile); err != nil { if err := a.runGitCommit(c, successUpgradedModules, existVendor, useDepFile); err != nil {
return err return err
} }
@ -249,8 +240,14 @@ func (a *action) runGoMod(c *cli.Context, existVendor bool) error {
return nil return nil
} }
// go mod edit -toolchain=none
goModArgs := []string{"mod", "edit", "-toolchain=none"}
if _, err := exec.CommandContext(c.Context, "go", goModArgs...).CombinedOutput(); err != nil {
return fmt.Errorf("exec: failed to run go %+v: %w", strings.Join(goModArgs, " "), err)
}
// go mod tidy // go mod tidy
goModArgs := []string{"mod", "tidy"} goModArgs = []string{"mod", "tidy"}
goOutput, err := exec.CommandContext(c.Context, "go", goModArgs...).CombinedOutput() goOutput, err := exec.CommandContext(c.Context, "go", goModArgs...).CombinedOutput()
if err != nil { if err != nil {
return fmt.Errorf("exec: failed to run go %+v: %w", strings.Join(goModArgs, " "), err) return fmt.Errorf("exec: failed to run go %+v: %w", strings.Join(goModArgs, " "), err)
@ -267,6 +264,15 @@ func (a *action) runGoMod(c *cli.Context, existVendor bool) error {
a.log("Go output: %s\n", string(goOutput)) a.log("Go output: %s\n", string(goOutput))
} }
goMod, err := a.runReadGoMod()
if err != nil {
return err
}
if goMod.Toolchain != "" {
return ErrGoModExistToolchain
}
return nil return nil
} }
@ -286,14 +292,6 @@ func (a *action) runReadGoMod() (*GoMod, error) {
return goMod, nil return goMod, nil
} }
func (a *action) runVerifyGoMod(goMod *GoMod) error {
if goMod.Toolchain != "" {
return ErrGoModExistToolchain
}
return nil
}
func (a *action) runGitCommit(c *cli.Context, successUpgradedModules []*Module, existVendor, useDepFile bool) error { func (a *action) runGitCommit(c *cli.Context, successUpgradedModules []*Module, existVendor, useDepFile bool) error {
if a.flags.dryRun { if a.flags.dryRun {
return nil return nil