internal/goversion: add new package, move Go 1.x constant there out of go/build

Found by Josh, who says in the bug that it shrinks cmd/compile by 1.6 MB (6.5%).

Fixes #31563

Change-Id: I35127af539630e628a0a4f2273af519093536c38
Reviewed-on: https://go-review.googlesource.com/c/go/+/172997
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
This commit is contained in:
Brad Fitzpatrick 2019-04-19 16:09:17 +00:00
parent 97252f620f
commit 64e29f94e2
6 changed files with 52 additions and 13 deletions

View file

@ -19,7 +19,7 @@ import (
"cmd/internal/sys"
"flag"
"fmt"
"go/build"
"internal/goversion"
"io"
"io/ioutil"
"log"
@ -1426,8 +1426,7 @@ var flag_lang string
// currentLang returns the current language version.
func currentLang() string {
tags := build.Default.ReleaseTags
return tags[len(tags)-1]
return fmt.Sprintf("go1.%d", goversion.Version)
}
// goVersionRE is a regular expression that matches the valid