Skip to content

Commit 68d895d

Browse files
committed
replace deprecated ioutil
1 parent 712d96a commit 68d895d

File tree

3 files changed

+29
-33
lines changed

3 files changed

+29
-33
lines changed

internal/model/github/contribution/heatmap.go

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,10 @@ func OrderByFrequency(in []HistogramByCountRow) sort.Interface { return orderByF
103103

104104
// HistogramByCount returns the distribution of amount contributions.
105105
//
106-
// 1 #
107-
// 3 #####
108-
// 4 ##
109-
// 7 ###
110-
//
106+
// 1 #
107+
// 3 #####
108+
// 4 ##
109+
// 7 ###
111110
func HistogramByCount(chm HeatMap, order ...func([]hbc) sort.Interface) []HistogramByCountRow {
112111
h := make([]hbc, 0, 8)
113112
m := make(map[int]int)
@@ -139,16 +138,15 @@ type hbd = HistogramByDateRow
139138
// The first value is a date in the specified format, and the second is a sum.
140139
// The result is sorted by the first value.
141140
//
142-
// format: time.RFC3339Day
143-
// 2022-01-02 #
144-
// 2022-01-04 ###
145-
// 2022-01-05 ##
146-
// 2022-02-01 #
147-
//
148-
// format: time.RFC3339Month
149-
// 2022-01 ######
150-
// 2022-02 #
141+
// format: time.RFC3339Day
142+
// 2022-01-02 #
143+
// 2022-01-04 ###
144+
// 2022-01-05 ##
145+
// 2022-02-01 #
151146
//
147+
// format: time.RFC3339Month
148+
// 2022-01 ######
149+
// 2022-02 #
152150
func HistogramByDate(chm HeatMap, format string) []HistogramByDateRow {
153151
h := make([]hbd, 0, 8)
154152
m := make(map[string]int)
@@ -179,17 +177,16 @@ type hbw = HistogramByWeekdayRow
179177
// The first value is a date in the specified format, and the second is a sum.
180178
// The result is sorted by the first value.
181179
//
182-
// grouped: false
183-
// Monday #
184-
// Tuesday ###
185-
// Friday ##
186-
// Monday #
187-
//
188-
// grouped: true
189-
// Monday ##
190-
// Tuesday ###
191-
// Friday ##
180+
// grouped: false
181+
// Monday #
182+
// Tuesday ###
183+
// Friday ##
184+
// Monday #
192185
//
186+
// grouped: true
187+
// Monday ##
188+
// Tuesday ###
189+
// Friday ##
193190
func HistogramByWeekday(chm HeatMap, grouped bool) []HistogramByWeekdayRow {
194191
f := make([]time.Time, 0, len(chm))
195192
for ts := range chm {

internal/pkg/time/range.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,10 @@ func BeforeOrEqual(t, u time.Time) bool {
2222
// Between returns true if min <= u, u <= max.
2323
// If you want to exclude some border, please use built-in Before or After methods:
2424
//
25-
// - [from, to]: Between(u, from, to)
26-
// - (from, to): from.Before(u) && to.After(u)
27-
// - [from, to): BeforeOrEqual(from, u) && to.After(u)
28-
// - (from, to]: from.Before(u) && AfterOrEqual(to, u)
29-
//
25+
// - [from, to]: Between(u, from, to)
26+
// - (from, to): from.Before(u) && to.After(u)
27+
// - [from, to): BeforeOrEqual(from, u) && to.After(u)
28+
// - (from, to]: from.Before(u) && AfterOrEqual(to, u)
3029
func Between(from, to, u time.Time) bool {
3130
return BeforeOrEqual(from, u) && AfterOrEqual(to, u)
3231
}

main_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package main
22

33
import (
4-
"io/ioutil"
4+
"io"
55
"os"
66
"testing"
77

@@ -12,21 +12,21 @@ import (
1212
func TestExecution(t *testing.T) {
1313
t.Run("success", func(t *testing.T) {
1414
exit = func(code int) { assert.Equal(t, 0, code) }
15-
stderr, stdout = ioutil.Discard, ioutil.Discard
15+
stderr, stdout = io.Discard, io.Discard
1616
os.Args = []string{"root", "version"}
1717
main()
1818
})
1919

2020
t.Run("failure", func(t *testing.T) {
2121
exit = func(code int) { assert.Equal(t, 1, code) }
22-
stderr, stdout = ioutil.Discard, ioutil.Discard
22+
stderr, stdout = io.Discard, io.Discard
2323
os.Args = []string{"root", "unknown"}
2424
main()
2525
})
2626

2727
t.Run("shutdown with panic", func(t *testing.T) {
2828
exit = func(code int) { assert.Equal(t, 1, code) }
29-
stderr, stdout = ioutil.Discard, ioutil.Discard
29+
stderr, stdout = io.Discard, io.Discard
3030
safe.Do(func() error { panic("test") }, shutdown)
3131
})
3232
}

0 commit comments

Comments
 (0)