Skip to content

Commit

Permalink
Merge pull request #40 from kazhuravlev/ka/improve-latest-version
Browse files Browse the repository at this point in the history
Improve latest version selector
  • Loading branch information
kazhuravlev authored Dec 27, 2024
2 parents 372bbc0 + 6fb21dd commit e87ad18
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ Temporary Items

### Other
.idea/
.toolset.json
.toolset.lock.json
bin/

coverage.txt
Expand Down
10 changes: 9 additions & 1 deletion internal/workdir/runtime-go/private.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ type moduleInfo struct {
IsPrivate bool // depends on `go env GOPRIVATE`
}

func (mi moduleInfo) IsLatest() bool {
return mi.Version == "latest"
}

// parse will parse source string and try to extract all details about mentioned golang program.
func parse(ctx context.Context, goBin, str string) (*moduleInfo, error) {
var canonical, mod, version, program string
Expand Down Expand Up @@ -135,7 +139,11 @@ func fetchLatest(ctx context.Context, goBin, link string) (*moduleInfo, error) {
return nil, fmt.Errorf("unable to decode module: %w", err)
}

mod2, err := parse(ctx, goBin, mod.Module+at+mod.Version)
resVersion := mod.Version
if mod.IsLatest() {
resVersion = fMod.Version
}
mod2, err := parse(ctx, goBin, mod.Module+at+resVersion)
if err != nil {
return nil, fmt.Errorf("parse fetched module: %w", err)
}
Expand Down

0 comments on commit e87ad18

Please sign in to comment.