July 27, 2021

Glice v2 - Adding support for go.mod

Glice has been the first open-source project I published on my GitHub account. It’s a dependency checker for Go that used to go through all .go files, parse the imports and fetch the licenses for third-party dependencies. Long overdue I’ve added support for projects using Go Modules and did a major refactor simultaneously.

Glice is a very simple Go project I wrote four years ago while still being new to the language. Previously it used Go’s built-in tooling (go-list) to parse imports of every .go file in a project, and output a list of all dependencies (including standard library ones), their count, and license and URL for third party ones.

The problems started once Go Modules were introduced. As Glice relied on GoPath and Go Modules got rid of that, Glice stopped working on projects utilizing the new modules. With time more and more projects adopted Go Modules and Glice became obsolete.

Due to a lack of time and motivation, I haven’t updated it for three years. Last week I was given a task to get all licenses our projects are using, which was ideal for updating Glice. It took me a couple of hours to rewrite it and add go.mod support. The actual code is now much simpler, parsing the go.mod file using modfile and fetching license information for all third party dependencies.

To simplify the project, I removed support for standard library dependencies and counting the number of times a dependency was imported. The previous version is available as v1.0.0 tag. Part of the API has been externalized which allows importing glice as a dependency and using it within your project.

Apart from replacing Travis (that appereantly went through some changes) with GitHub actions, thehre are a few things that could be improved - parallelizing dependency fetching and fetching the license for the exact version, not from master.

2018 © Emir Ribic - Some rights reserved; please attribute properly and link back. Code snippets are MIT Licensed

Powered by Hugo & Kiss.