github.com/shogo82148/std@v1.22.1-0.20240327122250-4e474527810c/cmd/go/internal/gover/mod.go (about) 1 // Copyright 2023 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 gover 6 7 import ( 8 "golang.org/x/mod/module" 9 ) 10 11 // IsToolchain reports whether the module path corresponds to the 12 // virtual, non-downloadable module tracking go or toolchain directives in the go.mod file. 13 // 14 // Note that IsToolchain only matches "go" and "toolchain", not the 15 // real, downloadable module "golang.org/toolchain" containing toolchain files. 16 // 17 // IsToolchain("go") = true 18 // IsToolchain("toolchain") = true 19 // IsToolchain("golang.org/x/tools") = false 20 // IsToolchain("golang.org/toolchain") = false 21 func IsToolchain(path string) bool 22 23 // ModCompare returns the result of comparing the versions x and y 24 // for the module with the given path. 25 // The path is necessary because the "go" and "toolchain" modules 26 // use a different version syntax and semantics (gover, this package) 27 // than most modules (semver). 28 func ModCompare(path string, x, y string) int 29 30 // ModSort is like module.Sort but understands the "go" and "toolchain" 31 // modules and their version ordering. 32 func ModSort(list []module.Version) 33 34 // ModIsValid reports whether vers is a valid version syntax for the module with the given path. 35 func ModIsValid(path, vers string) bool 36 37 // ModIsPrefix reports whether v is a valid version syntax prefix for the module with the given path. 38 // The caller is assumed to have checked that ModIsValid(path, vers) is true. 39 func ModIsPrefix(path, vers string) bool 40 41 // ModIsPrerelease reports whether v is a prerelease version for the module with the given path. 42 // The caller is assumed to have checked that ModIsValid(path, vers) is true. 43 func ModIsPrerelease(path, vers string) bool 44 45 // ModMajorMinor returns the "major.minor" truncation of the version v, 46 // for use as a prefix in "@patch" queries. 47 func ModMajorMinor(path, vers string) string