Skip to content

Commit d65d197

Browse files
authored
Fix linting errors (#16)
1 parent 8c36572 commit d65d197

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

diceware/generate.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ func RollWord(d int) (int, error) {
172172
func (g *Generator) RollDie() (int, error) {
173173
r, err := rand.Int(g.randReader, sides)
174174
if err != nil {
175-
return 0, err
175+
return 0, fmt.Errorf("failed to generate a random number: %w", err)
176176
}
177177
return int(r.Int64()) + 1, nil
178178
}

diceware/generate_test.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,13 @@ const (
1111
N = 10000
1212
)
1313

14-
func testUnique(t testing.TB, list []string) {
14+
func testUnique(tb testing.TB, list []string) {
15+
tb.Helper()
16+
1517
seen := make(map[string]struct{}, len(list))
1618
for _, v := range list {
1719
if _, ok := seen[v]; ok {
18-
t.Errorf("found duplicate: %q", list)
20+
tb.Errorf("found duplicate: %q", list)
1921
}
2022
seen[v] = struct{}{}
2123
}
@@ -82,8 +84,6 @@ func TestGenerateWordList(t *testing.T) {
8284
}
8385

8486
for _, tc := range cases {
85-
tc := tc
86-
8787
t.Run(tc.name, func(t *testing.T) {
8888
t.Parallel()
8989

diceware/word_list.go

+6-4
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,17 @@ type WordList interface {
1212
WordAt(int) string
1313
}
1414

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.
1717
type WordListNumWordser interface {
1818
// NumWords returns the total number of words in the list.
1919
NumWords() int
2020
}
2121

22-
var _ WordList = (*wordListInternal)(nil)
23-
var _ WordListNumWordser = (*wordListInternal)(nil)
22+
var (
23+
_ WordList = (*wordListInternal)(nil)
24+
_ WordListNumWordser = (*wordListInternal)(nil)
25+
)
2426

2527
type wordListInternal struct {
2628
digits int

0 commit comments

Comments
 (0)