Conversation
|
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/octolinker/octolinker-api/9hE4HcPkRq48d4miubUCZyMh9i5n |
| } | ||
|
|
||
| await cache.set(cacheKey, reachableUrl); | ||
| const [, targetUrl] = /UnitMeta-repo">[\n\s]+<a href="([^"]+)/g.exec(response.body); |
There was a problem hiding this comment.
Using a regex to scrape data off a website isn't ideal, but adding https://github.com/jsdom/jsdom doesn't help either if the classname changes. Ideally pkg.go.dev should expose a REST API, but this is not the case golang/go#36785 (yet?)
| ], | ||
| { firstMatch: true }, | ||
| ); | ||
| const isStdLib = response.body.includes('standard library'); |
There was a problem hiding this comment.
Without this check, import "context" would resolve to https://cs.opensource.google/go/go, but the actual https://pkg.go.dev/context might be more interesting in this case
|
Once this is live, we should be able to get rid off https://github.com/OctoLinker/OctoLinker/blob/343ff1e350d8c446ae3f152c747f9cf2b42331b9/packages/plugin-go/index.js#L52-L53 and use to |
|
Hey saw this by chance from the referenced issue. You can still get the vanity url resolver (if that's what you're after). If a package "name" starts with github.com, you're good to go. If it's anything else, you load the url with curl, and look for the |
Previously we had to do a weird dance to get the target url of a package by extracting that url from a meta-tag as explained here. This doesn't work anymore since
https://k8s.io/<package>got replaced byhttps://pkg.go.dev/<package>. Now pkg.go.dev seems to host all standard and external packages. This allows use to use pkg.go.dev as a single source. Unfortunately they don't have a REST API golang/go#36785 so we have to scrape the data from their website.