Something went wrong. Try again.
Something went wrong. Try again.
Files
- JavaScript 65%
- Go 25%
- TypeScript 9%
- Makefile <1%
README.md
go-vanity-pkg #
Go vanity URL server for Cloudflare Workers, free tier. Inspired by uber-go/sally and go.pixelfactory.io, but written in Go instead of TypeScript, built with syumai/workers-go (Go compiled to WebAssembly).
Serves the go-import / go-source meta tags that go get looks for, so
imports read:
import "go.daevix.com/daevix"
Installation #
go get go.daevix.com/daevix
Adding a package #
Edit packages.json and redeploy:
{
"domain": "go.daevix.com",
"godoc_host": "pkg.go.dev",
"packages": [
{
"path": "daevix",
"repo": "tangled.org/mads.havmand.eu/daevix"
}
]
}
path— vanity path (go.daevix.com/daevix)repo— backing git repository, without schemebranch— optional, default branch for source links (defaultmain)dir_template/file_template— optional overrides for thego-sourcelink templates (defaults match GitHub and tangled.org:tree/{branch}{/dir}andblob/{branch}{/dir}/{file}#L{line})
Development #
Requires mise (mise install provisions Go and Node).
make test # go test ./...
make build # compile app.wasm + worker.mjs
make dev # wrangler dev on http://localhost:8787
make deploy # wrangler deploy
How it works #
go get go.daevix.com/daevix fetches https://go.daevix.com/daevix?go-get=1
and reads the meta tags:
<meta name="go-import" content="go.daevix.com/daevix git https://tangled.org/mads.havmand.eu/daevix">
<meta name="go-source" content="go.daevix.com/daevix https://tangled.org/mads.havmand.eu/daevix https://tangled.org/mads.havmand.eu/daevix/tree/main{/dir} https://tangled.org/mads.havmand.eu/daevix/blob/main{/dir}/{file}#L{line}">
Browsers hitting the same URL get a meta refresh to
https://pkg.go.dev/go.daevix.com/daevix.
Longest-prefix matching: the package pkg/server matches before pkg,
and unknown paths return 404. / renders an index of all packages.