Thursday 3 November 2016

Getting Going

I'm now checking out Golang.

Some initial bumps were due to my expectations based on having largely lived in the JVM ecosystem in recent years.

Bump 1 - artefact repositories

There is intentionally no artefact repo (no maven central) for prebuilt objects. Instead you must build all dependencies from source. Then build your app.

This approach is familiar to anyone having built a C program like Apache using configure and make. You would download the source of the app and the source of the dependencies to disk. Then one at a time, for each dependency and for the app, you build it by telling configure where the source is on disk then kick off the configure. This spits out a makefile that can be run using make to build the component. Rinse and repeat until you have an executable.

The configure/make approach gets boring quickly and due to the effort involved and the desire for reproducibility one typically hand cranks a shell script to automate everything from the download to delivering the exe. Perhaps there are some fancy modern build tools for C out there but in haven't noticed them and what I described above is still the state of play for big products like Apache.

By contrast go build downloads all the sources of the dependencies automatically and builds them in the correct order to produce the exe. Go build works out the location to download the source from by virtue of cleverly embedding the github path into the import statements.

import (
"fmt"
"github.com/user/stringutil"
)

Bump 2 - dependency versions

Sooo .. my app has some dependencies. I was expecting to have to write a file somewhere declaring the versions of the dependencies in some manner.

But, bizarrely, the basic go build pattern has none of this.

It looks like go assumes you always want the latest versions of your dependencies no matter what you might like.

If you want reproducible builds them it would seem that you either check all the third party coffee into your git repository or use some 3rd party tooling.

---

Anyway I'm finding the language fun to work in.

I like the way functions are mapped to the data structures they relate to but I've not had a chance to look at what's available for immutability or threading or io or any other such fun.

Just getting started.

No comments:

Post a Comment

Hardware Hacking

Since the last post here I've taken to a bit of further hardware hacking and most of this is recorded on Hackaday  https://hackaday.io/j...