Skip to content

Commit

Permalink
Lazy load word lists until requested (#12)
Browse files Browse the repository at this point in the history
* Lazy load word lists until requested

* Cleanup CI
  • Loading branch information
sethvargo committed May 9, 2024
1 parent 6466c13 commit efcc200
Show file tree
Hide file tree
Showing 18 changed files with 17,039 additions and 17,040 deletions.
36 changes: 0 additions & 36 deletions .github/workflows/codeql.yml

This file was deleted.

23 changes: 0 additions & 23 deletions .github/workflows/lock.yml

This file was deleted.

28 changes: 0 additions & 28 deletions .github/workflows/stale.yml

This file was deleted.

49 changes: 28 additions & 21 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,40 @@ name: Test
on:
push:
branches:
- main
tags:
- '*'
- main
pull_request:
branches:
- main
- main

concurrency:
group: '${{ github.workflow }}-${{ github.head_ref || github.ref }}'
cancel-in-progress: true

jobs:
test:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
strategy:
matrix:
platform:
- 'macos-latest'
- 'ubuntu-latest'
- 'windows-latest'
fail-fast: false

- uses: actions/setup-go@v2
with:
go-version: '1.14'
runs-on: '${{ matrix.platform }}'

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

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

- name: Test
run: make test-acc
- shell: 'bash'
run: |-
go test \
-count=1 \
-race \
-shuffle=on \
-timeout=5m \
-vet=all \
./...
40 changes: 0 additions & 40 deletions Makefile

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
## Golang Diceware Generator

[![GoDoc](https://img.shields.io/badge/go-documentation-blue.svg?style=flat-square)](https://pkg.go.dev/github.com/sethvargo/go-diceware/diceware)
[![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)
[![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)

This library implements the [Diceware](https://en.wikipedia.org/wiki/Diceware)
algorithm in pure Golang. The algorithm is most-commonly used when generating
Expand Down
13 changes: 13 additions & 0 deletions cmd/diceware/main.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
// Copyright \d{4} .*
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// [\t\f]+|[ ]{2,}http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package main

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

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

import (
Expand All @@ -20,7 +20,7 @@ import (
"math/big"
)

// sides is the number of sides on a die
// sides is the number of sides on a die.
var sides = big.NewInt(6)

var _ DicewareGenerator = (*Generator)(nil)
Expand Down
15 changes: 14 additions & 1 deletion diceware/generate_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
// Copyright \d{4} .*
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// [\t\f]+|[ ]{2,}http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package diceware

import (
Expand Down Expand Up @@ -44,7 +57,7 @@ func TestGenerator_GenerateWithReader(t *testing.T) {
var firstList []string

for i := 0; i < 3; i++ {
gen, err := NewGenerator(&GeneratorInput{RandReader: bytes.NewBuffer([]byte(strings.Repeat("foopityboopityflippityfloppity", 16)))})
gen, err := NewGenerator(&GeneratorInput{RandReader: bytes.NewBufferString(strings.Repeat("foopityboopityflippityfloppity", 16))})
if err != nil {
t.Fatal(err)
}
Expand Down
13 changes: 13 additions & 0 deletions diceware/interface.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
// Copyright \d{4} .*
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// [\t\f]+|[ ]{2,}http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package diceware

type DicewareGenerator interface {
Expand Down
13 changes: 13 additions & 0 deletions diceware/mock.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
// Copyright \d{4} .*
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// [\t\f]+|[ ]{2,}http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package diceware

var _ DicewareGenerator = (*mockGenerator)(nil)
Expand Down
13 changes: 13 additions & 0 deletions diceware/word_list.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
// Copyright \d{4} .*
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// [\t\f]+|[ ]{2,}http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package diceware

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

0 comments on commit efcc200

Please sign in to comment.