Golang:go-humanize将文件大小转换成Kb、Mb、Gb适合人类阅读的单位

Golang:go-humanize将文件大小转换成Kb、Mb、Gb适合人类阅读的单位

图片

图片

最近去了昆明的教场中路体验了满屏蓝花楹,感受到了梦幻般的世界,随手拍了一张图,分享给大家,有时间可以去一趟,体验一次,顺便说一下,美女很多喔

 

Go Humans! (formatters for units to human friendly sizes)

译文:加油人类!(适合人类使用的单位的格式化程序)

文档

  • pkg.go https://pkg.go.dev/github.com/dustin/go-humanize
  • github https://github.com/dustin/go-humanize

安装

go get github.com/dustin/go-humanize

示例

package main

import (
    "fmt"

    "github.com/dustin/go-humanize"
)

func main() {

    fmt.Println(humanize.Bytes(8285))
    // 8.3 kB

    fmt.Println(humanize.Bytes(82854982))
    // 83 MB
}

 

回复:【golang加群】加入golang开发者交流群

golang · 目录
上一篇Golang:cast安全且易用的类型转换工具
阅读原文
阅读 233
 
1条留言
写留言
  •  
    golang加群
     
     
已无更多数据
 
 
 
 
 
 
 
 
 
posted @ 2024-05-04 16:24  技术颜良  阅读(52)  评论(0编辑  收藏  举报