Go-Libvirt is a pure Go interface for interacting with the toolkit Libvirt. DigitalOcean developed go-libvirt in 2016 to meet the company’s specific needs.

“At DigitalOcean, we use libvirt with QEMU to create and manage the virtual machines that compose our Droplet product. QEMU is the workhorse that enables hundreds of Droplets to run on a single server within our data centers. To perform management actions (like powering off a Droplet), we originally built automation which relied on shelling out to virsh, a command-line client used to interact with the libvirt daemon,” the company wrote in a blog post at the time. As we began to deploy Go into production, we realized we would need simple and powerful building blocks for future Droplet management tooling.”

The open source project can be used in conjunction with the company’s other project go-qemu, and manages VMs by proxying communication through libvirt daemon. This eliminates the need to communicate using cgo and C bindings. “While using the libvirt’s C bindings would be easier up front, we try to avoid cgo when possible,” the company wrote. “A pure Go library simplifies our build pipelines, reduces dependency headaches, and keeps cross-compilation simple.”

The project also uses code generation to build Go bindings. According to the company, libvirt’s RPC interface is very extensive and changes from one version to the next. Code generation  enables the library to be more resilient to any future changes in the libvirt API. The company explained that if the project adds a new API, the code generator will pick that up and generate bindings for it. Automation is crucial to code generation.

“Tedious, repetitive tasks are ideal candidates for automation,” the company said in an interview with SD Times. “That’s part of the reason code generation tools like Swagger (swagger.io) and gRPC (grpc.io) have been growing in popularity for developers building APIs. The same thing holds true for lower level language bindings. The Go programming language provides some built-in tools for generating code, allowing you to write programs that write programs.”

Top 5 trending projects on GitHub this week


  • Tensorflow: The ever resourceful machine learning framework brought to you by Google.
  • Nocode: What’s better than not coding. No code. This funny repository is getting a lot of hits this week! Still trending from last week!


    1. Automerge: A library of data structures for JavaScript apps


  • Checkstyle: A development tool to help programmers write Java code while adhering to a coding standard.