本文整理匯總了Golang中github.com/elastic/gosigar.FileSystemList類的典型用法代碼示例。如果您正苦於以下問題:Golang FileSystemList類的具體用法?Golang FileSystemList怎麽用?Golang FileSystemList使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了FileSystemList類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: GetFileSystemList75
func GetFileSystemList75() []string {
result := []string{}
volumes := []sigar.FileSystem{}
if runtime.GOOS == "windows" {
volumes = getWindowsDrives()
} else {
fslist := sigar.FileSystemList{}
fslist.Get()
volumes = fslist.List
}
for _, volume := range volumes {
dirName := volume.DirName
usage := sigar.FileSystemUsage{}
usage.Get(dirName)
if usage.UsePercent() >= 75 {
result = append(result, fmt.Sprintf("%s (%s)",
dirName,
sigar.FormatPercent(usage.UsePercent())))
}
}
return result
}
示例2: GetFileSystemList
func GetFileSystemList() ([]sigar.FileSystem, error) {
fss := sigar.FileSystemList{}
err := fss.Get()
if err != nil {
return nil, err
}
return fss.List, nil
}
示例3: main
func main() {
fslist := gosigar.FileSystemList{}
fslist.Get()
fmt.Fprintf(os.Stdout, output_format,
"Filesystem", "Size", "Used", "Avail", "Use%", "Mounted on")
for _, fs := range fslist.List {
dir_name := fs.DirName
usage := gosigar.FileSystemUsage{}
usage.Get(dir_name)
fmt.Fprintf(os.Stdout, output_format,
fs.DevName,
gosigar.FormatSize(usage.Total),
gosigar.FormatSize(usage.Used),
gosigar.FormatSize(usage.Avail),
gosigar.FormatPercent(usage.UsePercent()),
dir_name)
}
}