@@ -29,6 +29,8 @@ import (
29
29
"golang.org/x/pkgsite/internal"
30
30
"golang.org/x/pkgsite/internal/derrors"
31
31
"golang.org/x/pkgsite/internal/godoc/dochtml/internal/render"
32
+ "golang.org/x/pkgsite/internal/log"
33
+ "golang.org/x/pkgsite/internal/stdlib"
32
34
"golang.org/x/text/cases"
33
35
"golang.org/x/text/language"
34
36
)
@@ -442,15 +444,21 @@ func buildNoteHeaders(notes map[string][]*doc.Note) map[string]noteHeader {
442
444
}
443
445
444
446
// versionedPkgPath transforms package paths to contain the same version as the
445
- // current module if the package belongs to the module. As a special case,
446
- // versionedPkgPath will not add versions to standard library packages.
447
+ // current module if the package belongs to the module.
447
448
func versionedPkgPath (pkgPath string , modInfo * ModuleInfo ) string {
448
- if modInfo == nil || ! modInfo .ModulePackages [pkgPath ] {
449
+ if modInfo != nil && modInfo .ModulePath == "std" {
450
+ tag , err := stdlib .TagForVersion (modInfo .ResolvedVersion )
451
+ if err != nil {
452
+ log .Errorf (context .TODO (), "goTagForVersion(%q): %v" , modInfo .ResolvedVersion , err )
453
+ return pkgPath
454
+ }
455
+ return fmt .Sprintf ("%s@%s" , pkgPath , tag )
456
+ }
457
+
458
+ if modInfo == nil || (! modInfo .ModulePackages [pkgPath ]) {
449
459
return pkgPath
450
460
}
451
- // We don't need to do anything special here for standard library packages
452
- // since pkgPath will never contain the "std/" module prefix, and
453
- // modInfo.ModulePackages contains this prefix for standard library packages.
461
+
454
462
innerPkgPath := pkgPath [len (modInfo .ModulePath ):]
455
463
return fmt .Sprintf ("%s@%s%s" , modInfo .ModulePath , modInfo .ResolvedVersion , innerPkgPath )
456
464
}
0 commit comments