Source File
urlinfo.go
Belonging Package
golang.org/x/pkgsite/internal/frontend
package frontend
import (
)
func ( string) ( *urlPathInfo, error) {
defer derrors.Wrap(&, "extractURLPathInfo(%q)", )
:= strings.SplitN(strings.TrimPrefix(, "/"), "@", 2)
if stdlib.Contains([0]) {
return parseStdLibURLPath()
}
return parseDetailsURLPath()
}
func ( string) ( *urlPathInfo, error) {
defer derrors.Wrap(&, "parseDetailsURLPath(%q)", )
:= strings.SplitN(, "@", 2)
:= &urlPathInfo{
fullPath: strings.TrimSuffix(strings.TrimPrefix([0], "/"), "/"),
modulePath: internal.UnknownModulePath,
requestedVersion: internal.LatestVersion,
}
if [0] == internal.LatestVersion {
return nil, &userError{
err: fmt.Errorf("invalid version: %q", .requestedVersion),
userMessage: fmt.Sprintf("%q is not a valid version", [0]),
}
}
.requestedVersion = [0]
.modulePath = .fullPath
.fullPath = .fullPath + "/" +
}
}
if !isValidPath(.fullPath) {
return nil, &userError{
err: fmt.Errorf("isValidPath(%q) is false", .fullPath),
userMessage: fmt.Sprintf("%q is not a valid import path", .fullPath),
}
}
return , nil
}
func ( string) ( *urlPathInfo, error) {
defer derrors.Wrap(&, "parseStdLibURLPath(%q)", )
:= strings.SplitN(, "@", 2)
:= strings.TrimSuffix(strings.TrimPrefix([0], "/"), "/")
if !isValidPath() {
return nil, &userError{
err: fmt.Errorf("isValidPath(%q) is false", ),
userMessage: fmt.Sprintf("%q is not a valid import path", ),
}
}
:= &urlPathInfo{
fullPath: ,
modulePath: stdlib.ModulePath,
}
if len() == 1 {
.requestedVersion = internal.LatestVersion
return , nil
}
:= strings.TrimSuffix([1], "/")
.requestedVersion = stdlib.VersionForTag()
if .requestedVersion == "" {
return nil, &userError{
err: fmt.Errorf("invalid Go tag for url: %q", ),
userMessage: fmt.Sprintf("%q is not a valid tag for the standard library", ),
}
}
return , nil
}
func ( string) bool {
if := module.CheckImportPath(); != nil {
return false
}
:= strings.Split(, "/")
if [0] == "golang.org" {
if len() < 2 {
return false
}
switch [1] {
case "dl":
return true
case "x":
return len() >= 3
default:
return false
}
}
if vcsHostsWithThreeElementRepoName[[0]] && len() < 3 {
return false
}
return true
}
func ( context.Context, internal.DataSource, string) error {
, := .(*postgres.DB)
if ! {
return nil
}
, := .IsExcluded(, )
if != nil {
return
}
return &serverError{status: http.StatusNotFound}
}
return nil
}
func (, string) bool {
if , := internal.DefaultBranches[]; {
return !stdlib.Contains() || == "master"
}
return == internal.LatestVersion || semver.IsValid()
}
func ( context.Context, *http.Request) context.Context {
if := .ParseForm(); != nil {
log.Errorf(, "ParseForm: %v", )
return
}
return newContextFromExps(, .Form["exp"])
}
func ( context.Context, []string) context.Context {
var (
[]string
= map[string]bool{}
)
:= experiment.FromContext()
for , := range {
if strings.HasPrefix(, "!") {
= [1:]
if .IsActive() {
[] = true
}
} else if !.IsActive() {
= append(, )
}
}
if len() == 0 && len() == 0 {
return
}
for , := range .Active() {
if ![] {
= append(, )
}
}
return experiment.NewContext(, ...)
![]() |
The pages are generated with Golds v0.3.2-preview. (GOOS=darwin GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |