I noticed while importing packages from goji - it is hosted directly off their domain e.g:
package web
import (
"goji.io"
)
func Start() {
mux := goji.NewMux()
}
How are the packages being requested by go and how is it hosted in this way? I can't find any documentation, so I'm thinking it might be a neat trick.
It's documented in the go
command, under Remote Import Paths.
If the import path is not a known code hosting site and also lacks a version control qualifier, the go tool attempts to fetch the import over https/http and looks for a tag in the document's HTML .
The meta tag has the form:
<meta name="go-import" content="import-prefix vcs repo-root">
The import-prefix is the import path corresponding to the repository root. It must be a prefix or an exact match of the package being fetched with "go get". If it's not an exact match, another http request is made at the prefix to verify the tags match.