Skip to content

Commit ae17ffd

Browse files
authored
refactor package utils
1 parent 6d61aef commit ae17ffd

File tree

4 files changed

+42
-3
lines changed

4 files changed

+42
-3
lines changed

utils/date.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package utils
1+
package date_utils
22

33
import "time"
44

utils/file.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package utils
1+
package file_utils
22

33
import (
44
"os"

utils/int.go

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package int_utils
2+
3+
// Min returns the smallest integer from a list of integers.
4+
func Min(nums ...int) int {
5+
if len(nums) == 0 {
6+
return 0 // or some error value
7+
}
8+
min := nums[0]
9+
for _, num := range nums {
10+
if num < min {
11+
min = num
12+
}
13+
}
14+
return min
15+
}
16+
17+
// Max returns the largest integer from a list of integers.
18+
func Max(nums ...int) int {
19+
if len(nums) == 0 {
20+
return 0 // or some error value
21+
}
22+
max := nums[0]
23+
for _, num := range nums {
24+
if num > max {
25+
max = num
26+
}
27+
}
28+
return max
29+
}
30+
31+
// IsEven returns true if the integer is even.
32+
func IsEven(n int) bool {
33+
return n%2 == 0
34+
}
35+
36+
// IsOdd returns true if the integer is odd.
37+
func IsOdd(n int) bool {
38+
return n%2 != 0
39+
}

utils/strings.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package utils
1+
package strings_utils
22

33
import (
44
"regexp"

0 commit comments

Comments
 (0)