example  example

How to make your Go code go-getable with fossil (or other non-git vcs)?

godocs.io Go Reference

This repository contains short tutorial and resources for managing go source code with fossil VCS. It is also fully featured go package that you can reach and use with fossil clone and go get programs.

Prerequisites

  • Your own internet domain. They are very cheap today, especially if you choose some obscure tld like *.club or *.xyz.
  • 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.

VPS

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.

Github pages

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*.

Fossil server

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 repositories.

Meta tag

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 example.com/x/package you should create file package.html in the x directory in the root of your web server. Your 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">

Example meta tag for example.com/x/package import path and source code located at 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.

Testing

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.

Conclusion

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.


* You can probably accomplish above effect without any VPS with chisel and github pages without spending any penny, but I didn't test it.