Skip to content

Commit 537865d

Browse files
committed
feat: update support version to 1.24.x
1 parent 979362e commit 537865d

File tree

5 files changed

+13
-20
lines changed

5 files changed

+13
-20
lines changed

.github/workflows/go.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
runs-on: ${{ matrix.os }}
1616
strategy:
1717
matrix:
18-
go-version: ['1.17','1.18','1.20','1.21']
18+
go-version: ['1.17','1.18','1.20','1.21','1.22','1.23','1.24']
1919
os: [ ubuntu-latest, windows-latest, macOS-latest ]
2020
steps:
2121
- uses: actions/checkout@v3

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
module github.com/maogou/period
22

3-
go 1.21
3+
go 1.24
44

5-
require github.com/stretchr/testify v1.8.4
5+
require github.com/stretchr/testify v1.11.1
66

77
require (
88
github.com/davecgh/go-spew v1.1.1 // indirect

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb
44
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
55
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
66
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
7+
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
8+
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
79
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
810
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
911
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=

period.go

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@ type Period struct {
1111
}
1212

1313
func NewPeriod(startDate, endDate time.Time, boundaryType string) Period {
14-
if startDate.After(endDate) {
15-
startDate, endDate = endDate, startDate
16-
}
17-
1814
if _, ok := boundaryTypes[boundaryType]; !ok {
1915
boundaryType = IncludeStartExcludeEnd
2016
}
@@ -26,9 +22,6 @@ func NewPeriod(startDate, endDate time.Time, boundaryType string) Period {
2622
}
2723

2824
func NewDefaultPeriod(startDate, endDate time.Time) Period {
29-
if startDate.After(endDate) {
30-
startDate, endDate = endDate, startDate
31-
}
3225
return Period{
3326
startDate: startDate,
3427
endDate: endDate,
@@ -37,9 +30,6 @@ func NewDefaultPeriod(startDate, endDate time.Time) Period {
3730
}
3831

3932
func NewIncludeAllPeriod(startDate, endDate time.Time) Period {
40-
if startDate.After(endDate) {
41-
startDate, endDate = endDate, startDate
42-
}
4333
return Period{
4434
startDate: startDate,
4535
endDate: endDate,

period_test.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
package period
22

33
import (
4-
"github.com/stretchr/testify/assert"
54
"testing"
65
"time"
6+
7+
"github.com/stretchr/testify/assert"
78
)
89

910
func TestNewPeriod(t *testing.T) {
@@ -25,8 +26,8 @@ func TestNewPeriod(t *testing.T) {
2526
boundaryType: IncludeAll,
2627
},
2728
want: Period{
28-
startDate: time.Date(2023, 1, 1, 0, 0, 0, 0, time.Local),
29-
endDate: time.Date(2023, 1, 2, 0, 0, 0, 0, time.Local),
29+
startDate: time.Date(2023, 1, 2, 0, 0, 0, 0, time.Local),
30+
endDate: time.Date(2023, 1, 1, 0, 0, 0, 0, time.Local),
3031
boundaryType: IncludeAll,
3132
},
3233
},
@@ -83,8 +84,8 @@ func TestNewDefaultPeriod(t *testing.T) {
8384
endDate: time.Date(2023, 1, 1, 0, 0, 0, 0, time.Local),
8485
},
8586
want: Period{
86-
startDate: time.Date(2023, 1, 1, 0, 0, 0, 0, time.Local),
87-
endDate: time.Date(2023, 1, 2, 0, 0, 0, 0, time.Local),
87+
startDate: time.Date(2023, 1, 2, 0, 0, 0, 0, time.Local),
88+
endDate: time.Date(2023, 1, 1, 0, 0, 0, 0, time.Local),
8889
boundaryType: IncludeStartExcludeEnd,
8990
},
9091
},
@@ -128,8 +129,8 @@ func TestNewIncludeAllPeriod(t *testing.T) {
128129
endDate: time.Date(2023, 1, 1, 0, 0, 0, 0, time.Local),
129130
},
130131
want: Period{
131-
startDate: time.Date(2023, 1, 1, 0, 0, 0, 0, time.Local),
132-
endDate: time.Date(2023, 1, 2, 0, 0, 0, 0, time.Local),
132+
startDate: time.Date(2023, 1, 2, 0, 0, 0, 0, time.Local),
133+
endDate: time.Date(2023, 1, 1, 0, 0, 0, 0, time.Local),
133134
boundaryType: IncludeAll,
134135
},
135136
},

0 commit comments

Comments
 (0)