summaryrefslogtreecommitdiffstats
path: root/roseh.moe.go
diff options
context:
space:
mode:
authorRose Hogenson <rosehogenson@posteo.net>2026-10-14 07:21:50 -0700
committerRose Hogenson <rosehogenson@posteo.net>2026-10-14 07:22:26 -0700
commit0f40d4314dd79e3a985d67d5aa6489a867cc44ae (patch)
tree187ff60c99bd094bc49c0b46611a05cbfc82ccdf /roseh.moe.go
parentFix nix vendor hash (ugh) (diff)
downloadroseh.moe-0f40d4314dd79e3a985d67d5aa6489a867cc44ae.tar.zst
Support go-source meta tag
Diffstat (limited to 'roseh.moe.go')
-rw-r--r--roseh.moe.go18
1 files changed, 16 insertions, 2 deletions
diff --git a/roseh.moe.go b/roseh.moe.go
index 76e1e18..9a0d548 100644
--- a/roseh.moe.go
+++ b/roseh.moe.go
@@ -142,12 +142,14 @@ func loadSecrets() error {
type packageConfig struct {
Name string `xml:",attr"`
URL string `xml:",attr"`
+ Source string `xml:",attr"`
Description string `xml:",attr"`
}
type commandConfig struct {
Name string `xml:",attr"`
URL string `xml:",attr"`
+ Source string `xml:",attr"`
Description string `xml:",attr"`
Multi bool `xml:",attr"`
}
@@ -886,7 +888,14 @@ func cmd(w http.ResponseWriter, r *http.Request) {
return
}
if r.FormValue("go-get") == "1" {
- fmt.Fprintf(w, `<meta name="go-import" content="roseh.moe/cmd/%s %s">`, r.PathValue("cmd"), serviceConfig.CommandRedirects[sourceIdx].URL)
+ fmt.Fprintf(w, "<meta name=\"go-import\" content=\"roseh.moe/cmd/%s %s\">\n",
+ r.PathValue("cmd"),
+ serviceConfig.CommandRedirects[sourceIdx].URL)
+ if source := serviceConfig.CommandRedirects[sourceIdx].Source; source != "" {
+ fmt.Fprintf(w, "<meta name=\"go-source\" content=\"roseh.moe/cmd/%s %s\">\n",
+ r.PathValue("cmd"),
+ source)
+ }
} else {
http.Redirect(w, r, "https://pkg.go.dev/roseh.moe/cmd/"+r.PathValue("cmd"), http.StatusMovedPermanently)
}
@@ -949,7 +958,12 @@ func pkg(w http.ResponseWriter, r *http.Request) {
return
}
if r.FormValue("go-get") == "1" {
- fmt.Fprintf(w, `<meta name="go-import" content="roseh.moe/pkg/%s %s">`, r.PathValue("pkg"), serviceConfig.PackageRedirects[sourceIdx].URL)
+ fmt.Fprintf(w, "<meta name=\"go-import\" content=\"roseh.moe/pkg/%s %s\">\n", r.PathValue("pkg"), serviceConfig.PackageRedirects[sourceIdx].URL)
+ if source := serviceConfig.PackageRedirects[sourceIdx].Source; source != "" {
+ fmt.Fprintf(w, "<meta name=\"go-source\" content=\"roseh.moe/pkg/%s %s\">\n",
+ r.PathValue("pkg"),
+ source)
+ }
} else {
http.Redirect(w, r, "https://pkg.go.dev/roseh.moe/pkg/"+r.PathValue("pkg"), http.StatusMovedPermanently)
}