Thanks to visit codestin.com
Credit goes to github.com

Skip to content

compiler: discard metadata in VERSION file #1236

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 23, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions compiler/version_check.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ func CheckGoVersion(goroot string) error {
return nil
}

// goRootVersion defermines Go release for the given GOROOT installation.
// goRootVersion determines the Go release for the given GOROOT installation.
func goRootVersion(goroot string) (string, error) {
v, err := os.ReadFile(filepath.Join(goroot, "VERSION"))
if err == nil {
// Standard Go distribution has VERSION file inside its GOROOT, checking it
// is the most efficient option.
return string(v), nil
if b, err := os.ReadFile(filepath.Join(goroot, "VERSION")); err == nil {
// Standard Go distribution has a VERSION file inside its GOROOT,
// checking its first line is the most efficient option.
v, _, _ := strings.Cut(string(b), "\n")
return v, nil
}

// Fall back to the "go version" command.
Expand All @@ -58,8 +58,8 @@ func goRootVersion(goroot string) (string, error) {
return parts[2], nil
}

// GoRelease does a best-effort to identify Go release we are building with.
// If unable to determin the precise version for the given GOROOT, falls back
// GoRelease does a best-effort to identify the Go release we are building with.
// If unable to determine the precise version for the given GOROOT, falls back
// to the best guess available.
func GoRelease(goroot string) string {
v, err := goRootVersion(goroot)
Expand Down