github.com/glimps-jbo/go-licenses@v0.0.0-20230908151000-e06d3c113277/internal/third_party/pkgsite/version/version.go (about)

     1  // Copyright 2019 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  // Package version handles version types.
     6  package version
     7  
     8  import (
     9  	"regexp"
    10  	"strings"
    11  )
    12  
    13  const (
    14  	// Latest signifies the latest available version in requests to the
    15  	// proxy client.
    16  	Latest = "latest"
    17  
    18  	// Main represents the main branch.
    19  	Main = "main"
    20  
    21  	// Master represents the master branch.
    22  	Master = "master"
    23  )
    24  
    25  var pseudoVersionRE = regexp.MustCompile(`^v[0-9]+\.(0\.0-|\d+\.\d+-([^+]*\.)?0\.)\d{14}-[A-Za-z0-9]+(\+incompatible)?$`)
    26  
    27  // IsPseudo reports whether a valid version v is a pseudo-version.
    28  // Modified from src/cmd/go/internal/modfetch.
    29  func IsPseudo(v string) bool {
    30  	return strings.Count(v, "-") >= 2 && pseudoVersionRE.MatchString(v)
    31  }