Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
ollama
Commits
9f04e5a8
Commit
9f04e5a8
authored
Nov 14, 2023
by
Michael Yang
Browse files
format bytes
parent
f91bb2f7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
0 deletions
+3
-0
format/bytes.go
format/bytes.go
+3
-0
No files found.
format/bytes.go
View file @
9f04e5a8
...
@@ -7,10 +7,13 @@ const (
...
@@ -7,10 +7,13 @@ const (
KiloByte
=
Byte
*
1000
KiloByte
=
Byte
*
1000
MegaByte
=
KiloByte
*
1000
MegaByte
=
KiloByte
*
1000
GigaByte
=
MegaByte
*
1000
GigaByte
=
MegaByte
*
1000
TeraByte
=
GigaByte
*
1000
)
)
func
HumanBytes
(
b
int64
)
string
{
func
HumanBytes
(
b
int64
)
string
{
switch
{
switch
{
case
b
>
TeraByte
:
return
fmt
.
Sprintf
(
"%.1f TB"
,
float64
(
b
)
/
TeraByte
)
case
b
>
GigaByte
:
case
b
>
GigaByte
:
return
fmt
.
Sprintf
(
"%.1f GB"
,
float64
(
b
)
/
GigaByte
)
return
fmt
.
Sprintf
(
"%.1f GB"
,
float64
(
b
)
/
GigaByte
)
case
b
>
MegaByte
:
case
b
>
MegaByte
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment