在go中获取已卸载卷的BLKID

I am trying to find out if there is a way to get details of blkid of an unmounted volume, through some native golang library. I am particularly interested in fstype of the volume

I don't think there is a native library - I couldn't find one.

I think you've got 3 choices

  1. Shell out to the blkid utility
  2. Write a cgo interface to libblkid
  3. Trawl through the libblkid source and re-implement it in go

1 is very easy. 2 is harder. 3 might be easy depending on exactly which feature of blkid you want. strace blkid args and seem how many system calls it does to get the result you want to get an idea.

I'd probably go with 1. as blkid is one of the core linux tools which you are guaranteed to have I think.