chore(backend): replace go-units with go-humanize for improved file size handling

This commit is contained in:
keven1024
2025-06-01 21:48:36 +08:00
parent e1edff57db
commit 52da9960b8
3 changed files with 6 additions and 7 deletions

View File

@@ -4,7 +4,7 @@ go 1.23.1
require (
dario.cat/mergo v1.0.1
github.com/docker/go-units v0.5.0
github.com/dustin/go-humanize v1.0.1
github.com/golang-jwt/jwt/v5 v5.2.2
github.com/googollee/go-socket.io v1.7.0
github.com/gorilla/sessions v1.4.0

View File

@@ -11,8 +11,8 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78=
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc=
github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4=
github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8=
github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0=
github.com/fsnotify/fsnotify v1.8.0 h1:dAwr6QBTBZIkG8roQaJjGof0pp0EeF+tNV7YBP3F/8M=

View File

@@ -8,7 +8,7 @@ import (
"os"
"path/filepath"
goUnits "github.com/docker/go-units"
humanize "github.com/dustin/go-humanize"
)
func GetFileId(fileHash string, fileSize int64) string {
@@ -48,7 +48,6 @@ func GetUploadDirPath() (string, error) {
return uploadPath, nil
}
func GetFileSize(size string) (int64, error) {
s, err := goUnits.FromHumanSize(size)
return s, err
func GetFileSize(size string) (uint64, error) {
return humanize.ParseBytes(size)
}