This is an explanation of the video content.
 用技术延续对ACG的热爱
136

 |   | 

Go获取磁盘占用情况
package main

import (
	"fmt"
	"github.com/shirou/gopsutil/disk"
)

func main() {
	partitions, err := disk.Partitions(false)
	if err != nil {
		fmt.Printf("Failed to get disk partitions: %v", err)
		return
	}

	for _, partition := range partitions {
		usage, err := disk.Usage(partition.Mountpoint)
		if err != nil {
			fmt.Printf("Failed to get disk usage for %s: %v", partition.Mountpoint, err)
			continue
		}

		fmt.Printf("Mountpoint: %s\n", partition.Mountpoint)
		fmt.Printf("Total disk space: %d bytes\n", usage.Total)
		fmt.Printf("Used disk space: %d bytes\n", usage.Used)
		fmt.Printf("Free disk space: %d bytes\n", usage.Free)
		fmt.Printf("Usage percentage: %.2f%%\n", usage.UsedPercent)
		fmt.Println()
	}
}

136 服务端 ↦ Go开发技巧 __ 86 字
 Go开发技巧 #3