4
4
5
5
// Package module defines the module.Version type along with support code.
6
6
//
7
- // The module.Version type is a simple Path, Version pair:
7
+ // The [ module.Version] type is a simple Path, Version pair:
8
8
//
9
9
// type Version struct {
10
10
// Path string
11
11
// Version string
12
12
// }
13
13
//
14
14
// There are no restrictions imposed directly by use of this structure,
15
- // but additional checking functions, most notably Check, verify that
15
+ // but additional checking functions, most notably [ Check] , verify that
16
16
// a particular path, version pair is valid.
17
17
//
18
18
// # Escaped Paths
@@ -140,7 +140,7 @@ type ModuleError struct {
140
140
Err error
141
141
}
142
142
143
- // VersionError returns a ModuleError derived from a Version and error,
143
+ // VersionError returns a [ ModuleError] derived from a [ Version] and error,
144
144
// or err itself if it is already such an error.
145
145
func VersionError (v Version , err error ) error {
146
146
var mErr * ModuleError
@@ -169,7 +169,7 @@ func (e *ModuleError) Unwrap() error { return e.Err }
169
169
// An InvalidVersionError indicates an error specific to a version, with the
170
170
// module path unknown or specified externally.
171
171
//
172
- // A ModuleError may wrap an InvalidVersionError, but an InvalidVersionError
172
+ // A [ ModuleError] may wrap an InvalidVersionError, but an InvalidVersionError
173
173
// must not wrap a ModuleError.
174
174
type InvalidVersionError struct {
175
175
Version string
@@ -193,8 +193,8 @@ func (e *InvalidVersionError) Error() string {
193
193
func (e * InvalidVersionError ) Unwrap () error { return e .Err }
194
194
195
195
// An InvalidPathError indicates a module, import, or file path doesn't
196
- // satisfy all naming constraints. See CheckPath, CheckImportPath,
197
- // and CheckFilePath for specific restrictions.
196
+ // satisfy all naming constraints. See [ CheckPath], [ CheckImportPath] ,
197
+ // and [ CheckFilePath] for specific restrictions.
198
198
type InvalidPathError struct {
199
199
Kind string // "module", "import", or "file"
200
200
Path string
@@ -294,7 +294,7 @@ func fileNameOK(r rune) bool {
294
294
}
295
295
296
296
// CheckPath checks that a module path is valid.
297
- // A valid module path is a valid import path, as checked by CheckImportPath,
297
+ // A valid module path is a valid import path, as checked by [ CheckImportPath] ,
298
298
// with three additional constraints.
299
299
// First, the leading path element (up to the first slash, if any),
300
300
// by convention a domain name, must contain only lower-case ASCII letters,
@@ -380,7 +380,7 @@ const (
380
380
// checkPath returns an error describing why the path is not valid.
381
381
// Because these checks apply to module, import, and file paths,
382
382
// and because other checks may be applied, the caller is expected to wrap
383
- // this error with InvalidPathError.
383
+ // this error with [ InvalidPathError] .
384
384
func checkPath (path string , kind pathKind ) error {
385
385
if ! utf8 .ValidString (path ) {
386
386
return fmt .Errorf ("invalid UTF-8" )
@@ -532,7 +532,7 @@ var badWindowsNames = []string{
532
532
// they require ".vN" instead of "/vN", and for all N, not just N >= 2.
533
533
// SplitPathVersion returns with ok = false when presented with
534
534
// a path whose last path element does not satisfy the constraints
535
- // applied by CheckPath, such as "example.com/pkg/v1" or "example.com/pkg/v1.2".
535
+ // applied by [ CheckPath] , such as "example.com/pkg/v1" or "example.com/pkg/v1.2".
536
536
func SplitPathVersion (path string ) (prefix , pathMajor string , ok bool ) {
537
537
if strings .HasPrefix (path , "gopkg.in/" ) {
538
538
return splitGopkgIn (path )
@@ -582,7 +582,7 @@ func splitGopkgIn(path string) (prefix, pathMajor string, ok bool) {
582
582
// MatchPathMajor reports whether the semantic version v
583
583
// matches the path major version pathMajor.
584
584
//
585
- // MatchPathMajor returns true if and only if CheckPathMajor returns nil.
585
+ // MatchPathMajor returns true if and only if [ CheckPathMajor] returns nil.
586
586
func MatchPathMajor (v , pathMajor string ) bool {
587
587
return CheckPathMajor (v , pathMajor ) == nil
588
588
}
@@ -622,7 +622,7 @@ func CheckPathMajor(v, pathMajor string) error {
622
622
// PathMajorPrefix returns the major-version tag prefix implied by pathMajor.
623
623
// An empty PathMajorPrefix allows either v0 or v1.
624
624
//
625
- // Note that MatchPathMajor may accept some versions that do not actually begin
625
+ // Note that [ MatchPathMajor] may accept some versions that do not actually begin
626
626
// with this prefix: namely, it accepts a 'v0.0.0-' prefix for a '.v1'
627
627
// pathMajor, even though that pathMajor implies 'v1' tagging.
628
628
func PathMajorPrefix (pathMajor string ) string {
@@ -643,7 +643,7 @@ func PathMajorPrefix(pathMajor string) string {
643
643
}
644
644
645
645
// CanonicalVersion returns the canonical form of the version string v.
646
- // It is the same as semver.Canonical(v) except that it preserves the special build suffix "+incompatible".
646
+ // It is the same as [ semver.Canonical] except that it preserves the special build suffix "+incompatible".
647
647
func CanonicalVersion (v string ) string {
648
648
cv := semver .Canonical (v )
649
649
if semver .Build (v ) == "+incompatible" {
@@ -652,8 +652,8 @@ func CanonicalVersion(v string) string {
652
652
return cv
653
653
}
654
654
655
- // Sort sorts the list by Path, breaking ties by comparing Version fields.
656
- // The Version fields are interpreted as semantic versions (using semver.Compare)
655
+ // Sort sorts the list by Path, breaking ties by comparing [ Version] fields.
656
+ // The Version fields are interpreted as semantic versions (using [ semver.Compare] )
657
657
// optionally followed by a tie-breaking suffix introduced by a slash character,
658
658
// like in "v0.0.1/go.mod".
659
659
func Sort (list []Version ) {
@@ -793,7 +793,7 @@ func unescapeString(escaped string) (string, bool) {
793
793
}
794
794
795
795
// MatchPrefixPatterns reports whether any path prefix of target matches one of
796
- // the glob patterns (as defined by path.Match) in the comma-separated globs
796
+ // the glob patterns (as defined by [ path.Match] ) in the comma-separated globs
797
797
// list. This implements the algorithm used when matching a module path to the
798
798
// GOPRIVATE environment variable, as described by 'go help module-private'.
799
799
//
0 commit comments