File tree 3 files changed +11
-9
lines changed
3 files changed +11
-9
lines changed Original file line number Diff line number Diff line change @@ -172,7 +172,7 @@ func RollWord(d int) (int, error) {
172
172
func (g * Generator ) RollDie () (int , error ) {
173
173
r , err := rand .Int (g .randReader , sides )
174
174
if err != nil {
175
- return 0 , err
175
+ return 0 , fmt . Errorf ( "failed to generate a random number: %w" , err )
176
176
}
177
177
return int (r .Int64 ()) + 1 , nil
178
178
}
Original file line number Diff line number Diff line change @@ -11,11 +11,13 @@ const (
11
11
N = 10000
12
12
)
13
13
14
- func testUnique (t testing.TB , list []string ) {
14
+ func testUnique (tb testing.TB , list []string ) {
15
+ tb .Helper ()
16
+
15
17
seen := make (map [string ]struct {}, len (list ))
16
18
for _ , v := range list {
17
19
if _ , ok := seen [v ]; ok {
18
- t .Errorf ("found duplicate: %q" , list )
20
+ tb .Errorf ("found duplicate: %q" , list )
19
21
}
20
22
seen [v ] = struct {}{}
21
23
}
@@ -82,8 +84,6 @@ func TestGenerateWordList(t *testing.T) {
82
84
}
83
85
84
86
for _ , tc := range cases {
85
- tc := tc
86
-
87
87
t .Run (tc .name , func (t * testing.T ) {
88
88
t .Parallel ()
89
89
Original file line number Diff line number Diff line change @@ -12,15 +12,17 @@ type WordList interface {
12
12
WordAt (int ) string
13
13
}
14
14
15
- // WordListNumWordser is an auxillary interface that returns the number of words
16
- // in the list. This is a separate interface for backwards compatability .
15
+ // WordListNumWordser is an auxiliary interface that returns the number of words
16
+ // in the list. This is a separate interface for backwards compatibility .
17
17
type WordListNumWordser interface {
18
18
// NumWords returns the total number of words in the list.
19
19
NumWords () int
20
20
}
21
21
22
- var _ WordList = (* wordListInternal )(nil )
23
- var _ WordListNumWordser = (* wordListInternal )(nil )
22
+ var (
23
+ _ WordList = (* wordListInternal )(nil )
24
+ _ WordListNumWordser = (* wordListInternal )(nil )
25
+ )
24
26
25
27
type wordListInternal struct {
26
28
digits int
You can’t perform that action at this time.
0 commit comments