Make sizes more human friendly

This commit is contained in:
Justin Hawkins 2022-01-15 23:10:46 +10:30
parent e3cfa6f309
commit 448caafd6b
3 changed files with 5 additions and 1 deletions

View File

@ -11,6 +11,7 @@ import (
"net" "net"
"os" "os"
"github.com/dustin/go-humanize"
"github.com/tardisx/netgiv/secure" "github.com/tardisx/netgiv/secure"
) )
@ -64,7 +65,7 @@ func (c *Client) Connect() error {
if err != nil { if err != nil {
panic(err) panic(err)
} }
log.Printf("%d: %s (%d bytes)", listPacket.Id, listPacket.Kind, listPacket.FileSize) log.Printf("%d: %s (%s)", listPacket.Id, listPacket.Kind, humanize.Bytes(uint64(listPacket.FileSize)))
} }
conn.Close() conn.Close()
log.Printf("done listing") log.Printf("done listing")

1
go.mod
View File

@ -3,6 +3,7 @@ module github.com/tardisx/netgiv
go 1.17 go 1.17
require ( require (
github.com/dustin/go-humanize v1.0.0 // indirect
github.com/h2non/filetype v1.1.3 // indirect github.com/h2non/filetype v1.1.3 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect github.com/mattn/go-isatty v0.0.14 // indirect
golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3 // indirect golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3 // indirect

2
go.sum
View File

@ -1,3 +1,5 @@
github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo=
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
github.com/h2non/filetype v1.1.3 h1:FKkx9QbD7HR/zjK1Ia5XiBsq9zdLi5Kf3zGyFTAFkGg= github.com/h2non/filetype v1.1.3 h1:FKkx9QbD7HR/zjK1Ia5XiBsq9zdLi5Kf3zGyFTAFkGg=
github.com/h2non/filetype v1.1.3/go.mod h1:319b3zT68BvV+WRj7cwy856M2ehB3HqNOt6sy1HndBY= github.com/h2non/filetype v1.1.3/go.mod h1:319b3zT68BvV+WRj7cwy856M2ehB3HqNOt6sy1HndBY=
github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y= github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y=