File tree 4 files changed +12
-8
lines changed
4 files changed +12
-8
lines changed Original file line number Diff line number Diff line change 1
- VERSION = 1.3.2
1
+ VERSION = 1.3.3
2
2
3
3
APP := http-file-server
4
4
PACKAGES := $(shell go list -f {{.Dir}} ./...)
Original file line number Diff line number Diff line change @@ -60,14 +60,14 @@ Or [download a binary](https://github.com/sgreben/http-file-server/releases/late
60
60
61
61
``` sh
62
62
# Linux
63
- curl -L https://github.com/sgreben/http-file-server/releases/download/1.3.2 /http-file-server_1.3.2_linux_x86_64 .tar.gz | tar xz
63
+ curl -L https://github.com/sgreben/http-file-server/releases/download/1.3.3 /http-file-server_1.3.3_linux_x86_64 .tar.gz | tar xz
64
64
65
65
# OS X
66
- curl -L https://github.com/sgreben/http-file-server/releases/download/1.3.2 /http-file-server_1.3.2_osx_x86_64 .tar.gz | tar xz
66
+ curl -L https://github.com/sgreben/http-file-server/releases/download/1.3.3 /http-file-server_1.3.3_osx_x86_64 .tar.gz | tar xz
67
67
68
68
# Windows
69
- curl -LO https://github.com/sgreben/http-file-server/releases/download/1.3.2 /http-file-server_1.3.2_windows_x86_64 .zip
70
- unzip versions_1.3.2_windows_x86_64 .zip
69
+ curl -LO https://github.com/sgreben/http-file-server/releases/download/1.3.3 /http-file-server_1.3.3_windows_x86_64 .zip
70
+ unzip versions_1.3.3_windows_x86_64 .zip
71
71
```
72
72
73
73
## Use it
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ package main
3
3
import (
4
4
"fmt"
5
5
"html/template"
6
+ "math"
6
7
"net/http"
7
8
"net/url"
8
9
"os"
@@ -65,17 +66,20 @@ func (f fileSizeBytes) String() string {
65
66
MB = 1024 * KB
66
67
GB = 1024 * MB
67
68
)
69
+ divBy := func (x int64 ) int {
70
+ return int (math .Round (float64 (f ) / float64 (x )))
71
+ }
68
72
switch {
69
73
case f < KB :
70
74
return fmt .Sprintf ("%d" , f )
71
75
case f < MB :
72
- return fmt .Sprintf ("%dK" , f / KB )
76
+ return fmt .Sprintf ("%dK" , divBy ( KB ) )
73
77
case f < GB :
74
- return fmt .Sprintf ("%dM" , f / MB )
78
+ return fmt .Sprintf ("%dM" , divBy ( MB ) )
75
79
case f >= GB :
76
80
fallthrough
77
81
default :
78
- return fmt .Sprintf ("%dG" , f / GB )
82
+ return fmt .Sprintf ("%dG" , divBy ( GB ) )
79
83
}
80
84
}
81
85
You can’t perform that action at this time.
0 commit comments