2 ms·
It’s called remote import path and it’s trivial to use your own domain. All you need is a meta tag in the HTML: <meta name="go-import" content="import-prefix
by oefrha 4y ago
It’s called remote import path and it’s trivial to use your own domain. All you need is a meta tag in the HTML:
<meta name="go-import" content="import-prefix vcs repo-root">
The code can reside anywhere, independent from the domain in the import path.
https://pkg.go.dev/cmd/go#hdr-Remote_import_paths https://pkg.go.dev/cmd/go#hdr-Remote_import_paths
Edit: I see in another comment that you tried to curl https://robpike.io/ivy https://robpike.io/ivy and got a 302 redirect to pkg.go.dev. That's meant for humans. You need to add ?go-get=1 for the go toolchain:
$ curl 'https://robpike.io/ivy?go-get=1'
<meta name="go-import" content="robpike.io/cmd/doc git https://github.com/robpike/doc.git"> ...
Personally I don't bother with responding differently based on the go-get query param. I just put a <meta http-equiv="refresh"> alongside the <meta name="go-import"> so that the whole thing can be served statically and still be useful to both humans and machines.