I want to get the data shown by lsblk
command in Linux 64-bit systems. Obviously I can call lsblk
and parse the output. My question is if there is a better way to do this in Go?
Thanks.
Since lsblk
is already available and already does what you want (gathering information from the system and synthesizing that information into the form you want), I'd think using it would be the best way.
The lsblk
source code is here: https://github.com/karelzak/util-linux/blob/master/misc-utils/lsblk.c. At first glance, personally, this seems nontrivial to replicate in Go, and probably worth the hassle of parsing output and testing for breakage when the util-linux package is updated.
That's ultimately a decision that has to be made for your individual project based on your particular criteria.