Skip to content

Commit

Permalink
Update system go installation for new format
Browse files Browse the repository at this point in the history
The endpoint on go.dev now returns additional text after the
version, \ntime.

This change trims off the second half of the output.

Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
  • Loading branch information
alexellis committed Nov 27, 2023
1 parent 60876e0 commit 8363b67
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion cmd/system/go.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,5 +131,11 @@ func getGoVersion() (string, error) {
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)

return strings.TrimSpace(string(body)), nil
content := strings.TrimSpace(string(body))
version, _, ok := strings.Cut(content, "\n")
if !ok {
return "", fmt.Errorf("format unexpected: %q", content)
}

return version, nil
}

0 comments on commit 8363b67

Please sign in to comment.