First of all, I know we are super busy so this idea is probably for a hackathon or a lazy weekend (;)) However, I think it’s worth bringing it to the surface.
What are vanity imports?
In Go, packages are usually referenced by a URL: import "github.com/status-im/status-protocol-go"
unless they are from the standard library then simple import "time"
is enough. You can also download packages/modules in the same way using go get
, for example: go get github.com/status-im/status-go
.
What you notice here is that go get
hits github.com. How does it know how to download a package by looking at a regular HTLM page? Like with mobile Web Apps on iOS and very likely on Android, github.com provides a special meta
tag which would work on any other website:
<meta name="go-import" content="github.com/status-im/status-protocol-go git https://github.com/status-im/status-protocol-go.git">
It tells go get
about the type and URL of the repository.
And that’s the magic trick.
Why would we need this?
We don’t necessarily need this but having our own domain which we can use and advertise to import our Go packages has a couple of nice properties:
- We are independent from Github. Let’s say we need to move out from Github due to some reason. It’s enough to upload code to some other hosting and update the meta tag. That’s it. Currently, we would need to tell everyone through some communication mean that all addresses of our packages changed.
- It’s getting serious That’s the message you communicate when you have a vanity import.
- Promotion and directing the traffic as it’s still unusual to see vanity import addresses and it just draws users’ attention to visit the website.
- Import URLs are shorter.
It’s important to say that it does not mean we would need to move from Github now. We can still have our code there and do it like this:
<meta name="go-import" content="go.status.im/protocol git https://github.com/status-im/status-protocol-go">
Having something like go.status.im/protocol
instead of github.com/status-im/status-go
would be pretty cool, right?
cc @oskarth because of the new initiative https://vac.dev/ and you may want to host Go packages as go.vac.dev or something similar
cc @jakubgs because you are the master of our servers and capable of making it happen!