internal/postgres: prefer longest module path

The go command determines the latest minor version by picking the
longest module path that exists, then the latest version of that.

For example, given two "latest" possibilities for
cloud.google.com/go/pubsublite:

- cloud.google.com/go@v0.69.0/pubsublite
- cloud.google.com/go/pubsublite@v0.4.0

"go get cloud.google.com/go/pubsublite" will choose
cloud.google.com/go/pubsublite@v0.4.0.

Previously, pkg.go.dev/cloud.google.com/pubsublite would show
cloud.google.com/go@v0.69.0/pubsublite. This change updates the site to
display cloud.google.com/go/pubsublite@v0.4.0.

Note that given these two "latest" possibilities:

- cloud.google.com/go@v0.74.0/compute/metadata
- cloud.google.com/go/compute/metadata@v0.0.0-20181115181204-d50f0e9b2506

"go get cloud.google.com/go/compute/metadata" will return
cloud.google.com/go@v0.74.0/compute/metadata.

The reason is because "go get cloud.google.com/go/compute/metadata" will
look for tagged versions of the module
cloud.google.com/go/compute/metadata. Not finding any, it will look for
the pseudo-version for the current tip of the default branch. Since
today, there's no go.mod there, it proceeds as if this subdirectory was
never a nested module. It will then try "cloud.google.com/go/compute"
and so on until it eventually finds that
cloud.google.com/go@v0.74.0/compute/metadata has this package.

Pkg.go.dev/cloud.google.com/go/compute/metadata already shows
cloud.google.com/go@v0.74.0/compute/metadata. A test is added to verify
this logic.

Fixes golang/go#43166

Change-Id: I748fd2693ad7be761e49df9da285902c6dd9101d
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/277512
Run-TryBot: Julie Qiu <julie@golang.org>
Trust: Julie Qiu <julie@golang.org>
Reviewed-by: Jamal Carvalho <jamal@golang.org>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2 files changed
tree: 29d463262decdd49ba11269bf0a6bfba070924ac
  1. cmd/
  2. content/
  3. devtools/
  4. doc/
  5. internal/
  6. migrations/
  7. third_party/
  8. .dockerignore
  9. .gitignore
  10. .prettierignore
  11. .prettierrc.yaml
  12. all.bash
  13. cloudbuild.yaml
  14. CONTRIBUTING.md
  15. go.mod
  16. go.sum
  17. LICENSE
  18. package-lock.json
  19. package.json
  20. PATENTS
  21. README.md
README.md

Pkg.go.dev

Go Reference

A site for discovering Go packages

Pkg.go.dev is a website for discovering and evaluating Go packages and modules.

You can check it out at https://pkg.go.dev.

Roadmap

Pkg.go.dev launched in November 2019, and is currently under active development by the Go team.

Here's what we are currently working on:

  • Design updates: We have some design changes planned for pkg.go.dev, to address UX feedback that we have received. You can expect a more cohesive search and navigation experience coming soon. We plan to share these designs for feedback once they are ready.

  • Godoc.org redirect: Longer term, we are working towards redirecting godoc.org traffic to pkg.go.dev. We know that there are features available on godoc.org that users want to see on pkg.go.dev, and we want to ensure that we address these. We’ve been keeping track of issues related to redirecting godoc.org traffic on Go issue #39144. These issues will be prioritized in the next few months. We also plan to continue improving our license detection algorithm.

  • Search improvements: We’ll be improving our search experience based on feedback in Go issue #37810, to make it easier for users to find the dependencies they are looking for and make better decisions around which ones to import.

We encourage everyone to begin using pkg.go.dev today for all of their needs and to file feedback! You can redirect all of your requests from godoc.org to pkg.go.dev, by clicking Always use pkg.go.dev at the top of any page on godoc.org.

Issues

If you want to report a bug or have a feature suggestion, please first check the known issues to see if your issue is already being discussed. If an issue does not already exist, feel free to file an issue.

For answers to frequently asked questions, see go.dev/about.

You can also chat with us on the #tools slack channel on the Gophers slack.

Contributing

We would love your help!

Our canonical Git repository is located at go.googlesource.com/pkgsite. There is a mirror of the repository at github.com/golang/pkgsite.

To contribute, please read our contributing guide.

License

Unless otherwise noted, the Go source files are distributed under the BSD-style license found in the LICENSE file.

Links