stdlib

package
Version: v0.0.0-...-8893da0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 23, 2022 License: BSD-3-Clause Imports: 23 Imported by: 0

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

View Source
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"
)
View Source
const (
	GoRepoURL       = "https://go.googlesource.com/go"
	GoSourceRepoURL = "https://cs.opensource.google/go/go"

	GitHubRepo = "github.com/golang/go"
)
View Source
const EstimatedZipSize = 16 * 1024 * 1024

EstimatedZipSize is the approximate size of Zip("v1.15.2").

Variables

View Source
var (
	TestCommitTime     = time.Date(2019, 9, 4, 1, 2, 3, 0, time.UTC)
	TestMasterVersion  = "v0.0.0-20190904010203-89fb59e2e920"
	TestDevFuzzVersion = "v0.0.0-20190904010203-12de34vf56uz"
)

TestCommitTime is the time used for all commits when UseTestData is true.

View Source
var SupportedBranches = map[string]bool{
	version.Master:  true,
	DevBoringCrypto: true,
	DevFuzz:         true,
}

SupportedBranches are the branches of the stdlib repo supported by pkgsite.

Functions

func Contains

func Contains(path string) bool

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(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 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 Directory

func Directory(v string) string

Directory returns the directory of the standard library relative to the repo root.

func MajorVersionForVersion

func MajorVersionForVersion(version string) (_ string, err error)

MajorVersionForVersion returns the Go major version for version. E.g. "v1.13.3" => "go1".

func ResolveSupportedBranches

func ResolveSupportedBranches() (_ map[string]string, err error)

ResolveSupportedBranches returns the current hashes for each ref in SupportedBranches.

func SetGoRepoPath

func SetGoRepoPath(path string) error

SetGoRepoPath tells this package to obtain the Go repo from the local filesystem at path, instead of cloning it.

func TagForVersion

func TagForVersion(v string) (_ string, err error)

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

func VersionForTag(tag string) string

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

func VersionMatchesHash(v, hash string) bool

VersionMatchesHash reports whether v is a pseudo-version whose hash part matches the prefix of the given hash.

func Versions

func Versions() (_ []string, err error)

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:

defer WithTestData()()

func ZipInfo

func ZipInfo(requestedVersion string) (resolvedVersion string, err error)

ZipInfo returns the proxy .info information for the module std.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL