Skip to content

Commit efcc200

Browse files
authored
Lazy load word lists until requested (#12)
* Lazy load word lists until requested * Cleanup CI
1 parent 6466c13 commit efcc200

18 files changed

+17039
-17040
lines changed

.github/workflows/codeql.yml

-36
This file was deleted.

.github/workflows/lock.yml

-23
This file was deleted.

.github/workflows/stale.yml

-28
This file was deleted.

.github/workflows/test.yml

+28-21
Original file line numberDiff line numberDiff line change
@@ -3,33 +3,40 @@ name: Test
33
on:
44
push:
55
branches:
6-
- main
7-
tags:
8-
- '*'
6+
- main
97
pull_request:
108
branches:
11-
- main
9+
- main
10+
11+
concurrency:
12+
group: '${{ github.workflow }}-${{ github.head_ref || github.ref }}'
13+
cancel-in-progress: true
1214

1315
jobs:
1416
test:
15-
runs-on: ubuntu-latest
16-
17-
steps:
18-
- uses: actions/checkout@v2
17+
strategy:
18+
matrix:
19+
platform:
20+
- 'macos-latest'
21+
- 'ubuntu-latest'
22+
- 'windows-latest'
23+
fail-fast: false
1924

20-
- uses: actions/setup-go@v2
21-
with:
22-
go-version: '1.14'
25+
runs-on: '${{ matrix.platform }}'
2326

24-
- uses: actions/cache@v2
25-
with:
26-
path: ~/go/pkg/mod
27-
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
28-
restore-keys: |
29-
${{ runner.os }}-go-
27+
steps:
28+
- uses: 'actions/checkout@v4'
3029

31-
- name: Lint
32-
run: make fmtcheck staticcheck
30+
- uses: 'actions/setup-go@v5'
31+
with:
32+
go-version-file: 'go.mod'
3333

34-
- name: Test
35-
run: make test-acc
34+
- shell: 'bash'
35+
run: |-
36+
go test \
37+
-count=1 \
38+
-race \
39+
-shuffle=on \
40+
-timeout=5m \
41+
-vet=all \
42+
./...

Makefile

-40
This file was deleted.

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
## Golang Diceware Generator
22

33
[![GoDoc](https://img.shields.io/badge/go-documentation-blue.svg?style=flat-square)](https://pkg.go.dev/github.com/sethvargo/go-diceware/diceware)
4-
[![GitHub Actions](https://img.shields.io/github/workflow/status/sethvargo/go-envconfig/Test?style=flat-square)](https://github.com/sethvargo/go-diceware/actions?query=workflow%3ATest)
4+
[![GitHub Actions](https://img.shields.io/github/workflow/status/sethvargo/go-diceware/Test?style=flat-square)](https://github.com/sethvargo/go-diceware/actions?query=workflow%3ATest)
55

66
This library implements the [Diceware](https://en.wikipedia.org/wiki/Diceware)
77
algorithm in pure Golang. The algorithm is most-commonly used when generating

cmd/diceware/main.go

+13
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
// Copyright \d{4} .*
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// [\t\f]+|[ ]{2,}http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
114
package main
215

316
import (

diceware/diceware_doc_test.go

+13
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
// Copyright \d{4} .*
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// [\t\f]+|[ ]{2,}http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
114
package diceware_test
215

316
import (

diceware/generate.go

+14-14
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
// Package diceware provides a library for generating random words via the
2-
// diceware algorithm by rolling five six-sided dice to randomly select a word
3-
// from a list of english words.
4-
//
5-
// Read more about the diceware algorithm here: https://en.wikipedia.org/wiki/Diceware.
6-
//
7-
// list, err := diceware.Generate(6)
8-
// if err != nil {
9-
// log.Fatal(err)
10-
// }
11-
// log.Printf(strings.Join(list, "-"))
12-
//
13-
// Most functions are safe for concurrent use.
1+
// Copyright \d{4} .*
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// [\t\f]+|[ ]{2,}http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
1414
package diceware
1515

1616
import (
@@ -20,7 +20,7 @@ import (
2020
"math/big"
2121
)
2222

23-
// sides is the number of sides on a die
23+
// sides is the number of sides on a die.
2424
var sides = big.NewInt(6)
2525

2626
var _ DicewareGenerator = (*Generator)(nil)

diceware/generate_test.go

+14-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
// Copyright \d{4} .*
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// [\t\f]+|[ ]{2,}http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
114
package diceware
215

316
import (
@@ -44,7 +57,7 @@ func TestGenerator_GenerateWithReader(t *testing.T) {
4457
var firstList []string
4558

4659
for i := 0; i < 3; i++ {
47-
gen, err := NewGenerator(&GeneratorInput{RandReader: bytes.NewBuffer([]byte(strings.Repeat("foopityboopityflippityfloppity", 16)))})
60+
gen, err := NewGenerator(&GeneratorInput{RandReader: bytes.NewBufferString(strings.Repeat("foopityboopityflippityfloppity", 16))})
4861
if err != nil {
4962
t.Fatal(err)
5063
}

diceware/interface.go

+13
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
// Copyright \d{4} .*
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// [\t\f]+|[ ]{2,}http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
114
package diceware
215

316
type DicewareGenerator interface {

diceware/mock.go

+13
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
// Copyright \d{4} .*
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// [\t\f]+|[ ]{2,}http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
114
package diceware
215

316
var _ DicewareGenerator = (*mockGenerator)(nil)

diceware/word_list.go

+13
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
// Copyright \d{4} .*
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// [\t\f]+|[ ]{2,}http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
114
package diceware
215

316
// WordList is an interface that must be implemented to be considered a word

0 commit comments

Comments
 (0)