File tree Expand file tree Collapse file tree 5 files changed +9
-8
lines changed Expand file tree Collapse file tree 5 files changed +9
-8
lines changed Original file line number Diff line number Diff line change @@ -6,15 +6,15 @@ package utils
6
6
7
7
// ToLowerBytes converts ascii slice to lower-case
8
8
func ToLowerBytes (b []byte ) []byte {
9
- for i := 0 ; i < len ( b ); i ++ {
9
+ for i := range b {
10
10
b [i ] = toLowerTable [b [i ]]
11
11
}
12
12
return b
13
13
}
14
14
15
15
// ToUpperBytes converts ascii slice to upper-case
16
16
func ToUpperBytes (b []byte ) []byte {
17
- for i := 0 ; i < len ( b ); i ++ {
17
+ for i := range b {
18
18
b [i ] = toUpperTable [b [i ]]
19
19
}
20
20
return b
Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ import (
13
13
"os"
14
14
"reflect"
15
15
"runtime"
16
+ "slices"
16
17
"strconv"
17
18
"strings"
18
19
"sync"
@@ -105,12 +106,7 @@ func FunctionName(fn any) string {
105
106
106
107
// GetArgument check if key is in arguments
107
108
func GetArgument (arg string ) bool {
108
- for i := range os .Args [1 :] {
109
- if os .Args [1 :][i ] == arg {
110
- return true
111
- }
112
- }
113
- return false
109
+ return slices .Contains (os .Args [1 :], arg )
114
110
}
115
111
116
112
// IncrementIPRange Find available next IP address
Original file line number Diff line number Diff line change @@ -168,6 +168,7 @@ var mimeExtensions = map[string]string{
168
168
"shtml" : "text/html" ,
169
169
"css" : "text/css" ,
170
170
"xml" : "application/xml" ,
171
+ "cbor" : "application/cbor" ,
171
172
"gif" : "image/gif" ,
172
173
"jpeg" : "image/jpeg" ,
173
174
"jpg" : "image/jpeg" ,
Original file line number Diff line number Diff line change @@ -32,6 +32,9 @@ func Test_GetMIME(t *testing.T) {
32
32
res = GetMIME ("zst" )
33
33
require .Equal (t , "application/zstd" , res )
34
34
35
+ res = GetMIME ("cbor" )
36
+ require .Equal (t , "application/cbor" , res )
37
+
35
38
// empty case
36
39
res = GetMIME ("" )
37
40
require .Equal (t , "" , res )
Original file line number Diff line number Diff line change 7
7
// IsIPv4 works the same way as net.ParseIP,
8
8
// but without check for IPv6 case and without returning net.IP slice, whereby IsIPv4 makes no allocations.
9
9
func IsIPv4 (s string ) bool {
10
+ //nolint:modernize-loop // old way is more readable
10
11
for i := 0 ; i < net .IPv4len ; i ++ {
11
12
if len (s ) == 0 {
12
13
return false
You can’t perform that action at this time.
0 commit comments