Over a million developers have joined DZone.

Why It's Time For Go Packages to Start Versioning

The current state of versioning in Go projects and why it's worth it to start versioning now.

· DevOps Zone

The DevOps zone is brought to you in partnership with Sonatype Nexus. The Nexus suite helps scale your DevOps delivery with continuous component intelligence integrated into development tools, including Eclipse, IntelliJ, Jenkins, Bamboo, SonarQube and more. Schedule a demo today

tl;dr: Please provide semantically versioned releases of your packages and libraries.

Update: There is a proposal to bring semantic versioning to the Go community.

When it comes to package management the Go community is different from the rest. There are some places that's not a good thing and release versions happen to be one of them. In general Go packages, many of which are used in production, have no identifiable version other than a commit ID and that's a problem.

Why Bother Versioning?

There are theoretical and then there are practical reasons to version. I want to share a little of both by example.

  1. Kubernetes has quite a few dependencies. And its dependencies have dependencies. Sometimes they share a dependency but list different versions of it. If you took the version specified by Kubernetes and the versions specified by their dependencies you'll find 42 conflicts (as or writing this post). A conflict is there two different versions are being specified (often in a Godep file). Since they are all specified as commit IDs there's not way to distinguish a difference. When I looked deeper (by hand) I found cases were versions could be years apart in time. This is not ideal.
  2. What if I asked you to use version f9885acc8cd1403afcd09570c89a009e8bd1dc19 of OpenSSL? Or, what if that's the version bundled in something you downloaded? Would you feel safe using that. Based on the commit ID there's no real way to tell when it came from. Is it safe? It's not safe. This version is susceptible to Heartbleed. No one does this with OpenSSL. They use versions so a simple version comparison can tell if it's safe. Thankfully OpenSSL doesn't version by commit ID.
  3. Stability can be an issue. I was recently working on a project that pulled in some 3rd party libraries. The problem was one of stability. The latest commit wasn't stable. It didn't work. So, work had to be done to walk through the commits to find one that worked. This is tedious and annoying. If there are stable releases you can use that. It's not like most people run the latest commit of Go, Firefox, or well just about anything else.

Note, if you believe Go packages only need to be tied to the commit IDs then I challenge you to run everything that way. The Go toolchain, your browser, and all of it.

Other Language Communities

I've been looking at how other language communities handle packages. I decided to look at release versions in these communities and I was going to attempt to calculate a percent of packages in those communities that have release versions. But, I found that all the popular packages have releases and some communities require them. It was hard to find a package with any kind of adoption that didn't have releases. I didn't calculate a percentage because it's a tiny fraction of a percent.

The State of Go Versioning

So, how does Go compare? I used tools such as Godoc and Go Search to find the top packages. The packages fell into 5 categories:

  1. 9 of the top 20 most imported according to Go Search had no release versions at all. When I look at other lists on Godoc or Go Search these ratio of only about half having versions holds up. To go further I looked at GitHub Trends for Go packages (excluding applications written in Go) and found 75% for the past month didn't have release versions.
  2. Of those that have release versions many are out of date. It's not unusual to have the latest release be over a year old. Sometimes closer to two years. There can be many, sometimes hundreds of, commits since then. While these versioned releases exist they are essentially useless.
  3. Those who are using gopkg.in. These really fall into two categories. Those who are doing incremental releases and those who just have a major branch you need to follow. The latter is similar to not versioning except you have the major version API break handled. The former is great and I like to see it.
  4. Some have tags that have meaning only to that project. Are these releases? What do they mean? I don't know because it's not obvious. They appear to be one offs.
  5. Some use release versions, keep making releases, and I'm overjoyed to see them. It makes me smile when I see packages like beego and logrus releasing versions.

There's more to the state of Go besides the state of the releases on packages. You need tools that can leverage them. Here are a few:

  • gopkg.in has been around for some time to allow projects on GitHub to handle versions through imports.
  • Glide is a package manager for Go and the GO15VENDOREXPERIMENT. You can specify versions and ranges (e.g., ^1.2.3).
  • gb-vendor will let you specify tags that can be versions (no SemVer range filtering yet but I've read the Dave wants to add it).

We are starting to see the rise of tools that can use the versions intelligently.

Please Use Semantic Versioning

It's not only time to start versioning but to use semantic versioning (SemVer). SemVer is a specification and you can derive meaning from the version numbers allowing for useful comparisons. SemVer or something very similar is what every other programming language community uses. The newer language communities are using it explicitly. Since SemVer is a spec we don't need to argue about what should be in it and there are already packages allowing you to work with them.

It's time for the Go community to have semantically versioned releases of all packages. It's what all the mature language communities do. We should join them.

The DevOps zone is brought to you in partnership with Sonatype Nexus. Use the Nexus Suite to automate your software supply chain and ensure you're using the highest quality open source components at every step of the development lifecycle. Get Nexus today


Published at DZone with permission of Matt Farina, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}