How to make your Go code go-getable with fossil (or other non-git vcs)?
The post below is a copy from a wiki page from hauru.club/x/example
repository. It stores sample golang package hosted with fossil VCS. I’ve
had created it to show people how to manage golang packages with fossil VCS and be able to
download them with
go get tool.
- Your own internet domain. They are very cheap today, especially if you choose some obscure tld like
- Some VPS. You can use this referral link to gain some free credits during registration at vultr.
- Go compiler, some text editor, cool project name etc.
I won’t give you detailed instructions on how to setup your own domain and VPS, because it is not in the scope of this document and folks smarter than me had prepared good materials regarding setup and maintenance of VPSes.
If you don’t want to manage your own web server you can just use github pages with your domain. But you still need some place to self-host fossil anyway*.
Follow actual fossil documentation,
it consists a lot of practical examples and answers most questions. Remember that
you can use
--repolist flag of
fossil server subcommand to
serve multiple fossil
You should add special page with the same directory path as the desirable go import
path. For example: if you want your import path to be
should create file
package.html in the
x directory in the root of your web server.
package.html document has to contain special
<meta> tag in the head node.
According to go documentation, the
meta tag has the form:
<meta name="go-import" content="import-prefix vcs repo-root">
meta tag for
example.com/x/package import path and source code located
https://fossil.example.com/package managed by fossil VCS could looks like:
<meta name="go-import" content="example.com/x/package fossil https://fossil.example.com/package">
You can add more pages for other go projects with the corresponding meta tag.
If everything is properly setup you should be able to download your source code for
project with valid
go.mod file by typing
go get example.com/x/package command in
your terminal window. You can also check if the documentation for your project is
available at the godocs.io or pkg.go.dev.
Having your own custom go import path isn’t really a thing. Nothing stops you from using the knowledge and experience from this tutorial to make your project go-getable with vcs other than the fossil. You may also want to setup custom go import paths for your projects hosted at github.
If you want to share some thoughts after reading this post, feel free to contact me.