try to fix building with go.work

This commit is contained in:
Jeff Carr 2024-12-15 08:46:01 -06:00
parent 84cf8265a0
commit 8018774c10
2 changed files with 5 additions and 5 deletions

View File

@ -26,7 +26,7 @@ func (a args) Description() string {
go-mod-clean will try to verify your go.* files are using the newest package versions
* Recreate go.* with 'go mod init' and 'go mod tidy'
* Set your required go in go.mod (default is go1.20
* Set your required go in go.mod (default is go1.21
* Check that the most recent master branch versions are used
* Try to trim go.sum of non-existent entries
`

View File

@ -21,7 +21,7 @@ func eraseGoMod(repo *gitpb.Repo) {
// sets the required golang version in go.mod
func setGoVersion(repo *gitpb.Repo, version string) error {
// most things should build with golang after 1.20
// most things should build with golang after 1.21
if err := repo.StrictRun([]string{"go", "mod", "edit", "-go=" + version}); err != nil {
log.Warn(repo.GoPath, "go mod edit failed", err)
return err
@ -41,13 +41,13 @@ func redoGoMod(repo *gitpb.Repo) error {
log.Warn("go mod init failed", err)
return err
}
if err := repo.StrictRun([]string{"go", "mod", "tidy"}); err != nil {
if err := repo.StrictRun([]string{"go", "mod", "tidy", "-go=1.21"}); err != nil {
log.Warn("go mod tidy failed", err)
return err
}
// most things should build with golang after 1.20 // todo: allow this to be set somewhere
if err := setGoVersion(repo, "1.20"); err != nil {
// most things should build with golang after 1.21 // todo: allow this to be set somewhere
if err := setGoVersion(repo, "1.21"); err != nil {
log.Warn(repo.GoPath, "go mod edit failed", err)
return err
}