-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tweak go resolver #444
base: master
Are you sure you want to change the base?
Tweak go resolver #444
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.