Package stdlib supports special handling of the Go standard library. Regardless of the how the standard library has been split into modules for development and testing, the discovery site treats it as a single module named "std".
- func Contains(path string) bool
- func ContentDir(requestedVersion string) (_ fs.FS, resolvedVersion string, commitTime time.Time, err error)
- func Directory(v string) string
- func MajorVersionForVersion(version string) (_ string, err error)
- func ResolveSupportedBranches() (_ map[string]string, err error)
- func SetGoRepoPath(path string) error
- func TagForVersion(v string) (_ string, err error)
- func VersionForTag(tag string) string
- func VersionMatchesHash(v, hash string) bool
- func Versions() (_ string, err error)
- func WithTestData() func()
- func ZipInfo(requestedVersion string) (resolvedVersion string, err error)
const ( // ModulePath is the name of the module for the standard library. ModulePath = "std" // DevFuzz is the branch name for fuzzing in beta. DevFuzz = "dev.fuzz" // DevBoringCrypto is the branch name for dev.boringcrypto. DevBoringCrypto = "dev.boringcrypto" )
const ( GoRepoURL = "https://go.googlesource.com/go" GoSourceRepoURL = "https://cs.opensource.google/go/go" GitHubRepo = "github.com/golang/go" )
const EstimatedZipSize = 16 * 1024 * 1024
EstimatedZipSize is the approximate size of Zip("v1.15.2").
TestCommitTime is the time used for all commits when UseTestData is true.
SupportedBranches are the branches of the stdlib repo supported by pkgsite.
Contains reports whether the given import path could be part of the Go standard library, by reporting whether the first component lacks a '.'.
func ContentDir ¶
ContentDir creates an fs.FS representing the entire Go standard library at the given version (which must have been resolved with ZipInfo) and returns a reader to it. It also returns the time of the commit for that version.
Normally, ContentDir returns the resolved version it was passed. If the resolved version is a supported branch like "master", ContentDir returns a semantic version for the branch.
ContentDir reads the standard library at the Go repository tag corresponding to to the given semantic version.
ContentDir ignores go.mod files in the standard library, treating it as if it were a single module named "std" at the given version.
Directory returns the directory of the standard library relative to the repo root.
func MajorVersionForVersion ¶
MajorVersionForVersion returns the Go major version for version. E.g. "v1.13.3" => "go1".
ResolveSupportedBranches returns the current hashes for each ref in SupportedBranches.
func SetGoRepoPath ¶
SetGoRepoPath tells this package to obtain the Go repo from the local filesystem at path, instead of cloning it.
func TagForVersion ¶
TagForVersion returns the Go standard library repository tag corresponding to semver. The Go tags differ from standard semantic versions in a few ways, such as beginning with "go" instead of "v".
func VersionForTag ¶
VersionForTag returns the semantic version for the Go tag, or "" if tag doesn't correspond to a Go release or beta tag. In special cases, when the tag specified is either `latest` or `master` it will return the tag. Examples:
"go1" => "v1.0.0" "go1.2" => "v1.2.0" "go1.13beta1" => "v1.13.0-beta.1" "go1.9rc2" => "v1.9.0-rc.2" "latest" => "latest" "master" => "master"
func VersionMatchesHash ¶
VersionMatchesHash reports whether v is a pseudo-version whose hash part matches the prefix of the given hash.
Versions returns all the versions of Go that are relevant to the discovery site. These are all release versions (tags of the forms "goN.N" and "goN.N.N", where N is a number) and beta or rc versions (tags of the forms "goN.NbetaN" and "goN.N.NbetaN", and similarly for "rc" replacing "beta").
func WithTestData ¶
func WithTestData() func()
WithTestData arranges for this package to use a testing version of the Go repo. The returned function restores the previous state. Use with defer:
This section is empty.