Documentation ¶
Overview ¶
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".
Index ¶
- Constants
- Variables
- func Contains(path string) bool
- func ContentDir(ctx context.Context, 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)
Constants ¶
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").
const ModulePath = "std"
ModulePath is the name of the module for the standard library.
Variables ¶
var ( TestCommitTime = time.Date(2019, 9, 4, 1, 2, 3, 0, time.UTC) TestMasterVersion = "v0.0.0-20190904010203-89fb59e2e920" )
TestCommitTime is the time used for all commits when UseTestData is true.
SupportedBranches are the branches of the stdlib repo supported by pkgsite. This should always contain version.Master, and may sometimes have other branches if they are experiments that are announced to the community.
Functions ¶
func Contains ¶
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 ¶
func ContentDir(ctx context.Context, requestedVersion string) (_ fs.FS, resolvedVersion string, commitTime time.Time, err error)
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 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.
func MajorVersionForVersion ¶
MajorVersionForVersion returns the Go major version for version. E.g. "v1.13.3" => "go1".
func ResolveSupportedBranches ¶
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".
Starting with go1.21.0, the first patch release of major go versions include the .0 suffix. Previously, the .0 suffix was elided (golang/go#57631).
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.
func Versions ¶
Versions returns all the semantic versions of Go that are relevant to the discovery site. These are all release versions (derived from tags of the forms "goN.N" and "goN.N.N", where N is a number) and beta or rc versions (derived from 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:
defer WithTestData()()
Types ¶
This section is empty.