package
main
import
(
"fmt"
"github.com/StackExchange/wmi"
)
type
Storage
struct
{
Name string
FileSystem string
Total uint64
Free uint64
}
type
storageInfo
struct
{
Name string
Size uint64
FreeSpace uint64
FileSystem string
}
func
getStorageInfo() {
var
storageinfo []storageInfo
var
loaclStorages []Storage
err := wmi.Query(
"Select * from Win32_LogicalDisk"
, &storageinfo)
if
err != nil {
return
}
for
_, storage :=
range
storageinfo {
info := Storage{
Name: storage.Name,
FileSystem: storage.FileSystem,
Total: storage.Size,
Free: storage.FreeSpace,
}
loaclStorages = append(loaclStorages, info)
}
fmt.Printf(
"localStorages:="
, loaclStorages)
}
func
main() {
getStorageInfo()
}