• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

jedib0t / go-passwords / 20758063667

06 Jan 2026 06:19PM UTC coverage: 86.218% (+0.6%) from 85.646%
20758063667

Pull #8

github

jedib0t
update benchmark results in README
Pull Request #8: passphrase: minor optimizations to mem allocations

3 of 18 new or added lines in 3 files covered. (16.67%)

538 of 624 relevant lines covered (86.22%)

1.03 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/main.go
1
package main
2

3
import (
4
        "fmt"
5

6
        "github.com/jedib0t/go-passwords/charset"
7
        "github.com/jedib0t/go-passwords/enumerator"
8
        "github.com/jedib0t/go-passwords/passphrase"
9
        "github.com/jedib0t/go-passwords/passphrase/dictionaries"
10
        "github.com/jedib0t/go-passwords/password"
11
)
12

13
var (
14
        colorReset     = "\033[0m"
15
        colorBold      = "\033[1m"
16
        colorUnderline = "\033[4m"
17
)
18

19
func main() {
×
NEW
20
        report := func(name string, fn func()) {
×
NEW
21
                fmt.Printf("%s%s%s%s:\n", colorBold, colorUnderline, name, colorReset)
×
NEW
22
                fn()
×
NEW
23
                fmt.Println()
×
NEW
24
        }
×
25

NEW
26
        report("Enumerator", demoEnumerator)
×
NEW
27
        report("Passphrases", demoPassphraseGenerator)
×
NEW
28
        report("Passwords", demoPasswordGenerator)
×
29
}
30

NEW
31
func demoEnumerator() {
×
NEW
32
        o := enumerator.New(charset.AlphabetsUpper, 8)
×
33

×
NEW
34
        for idx := 1; idx <= 10; idx++ {
×
NEW
35
                fmt.Printf("Password #%3d: %#v\n", idx, o.String())
×
36

×
NEW
37
                if o.AtEnd() {
×
NEW
38
                        break
×
39
                }
NEW
40
                o.Increment()
×
41
        }
42
}
43

44
func demoPassphraseGenerator() {
×
45
        g, err := passphrase.NewGenerator(
×
46
                passphrase.WithCapitalizedWords(true),
×
47
                passphrase.WithDictionary(dictionaries.English()),
×
48
                passphrase.WithNumWords(3),
×
49
                passphrase.WithNumber(true),
×
50
                passphrase.WithSeparator("-"),
×
51
                passphrase.WithWordLength(4, 6),
×
52
        )
×
53
        if err != nil {
×
54
                panic(err.Error())
×
55
        }
56
        for idx := 1; idx <= 10; idx++ {
×
57
                phrase, err := g.Generate()
×
58
                if err != nil {
×
59
                        panic(err.Error())
×
60
                }
61
                fmt.Printf("Passphrase #%3d: %#v\n", idx, phrase)
×
62
        }
63
}
64

65
func demoPasswordGenerator() {
×
66
        g, err := password.NewGenerator(
×
67
                password.WithCharset(charset.AllChars.WithoutAmbiguity().WithoutDuplicates()),
×
68
                password.WithLength(12),
×
69
                password.WithMinLowerCase(5),
×
70
                password.WithMinUpperCase(2),
×
71
                password.WithNumSymbols(1, 1),
×
72
        )
×
73
        if err != nil {
×
74
                panic(err.Error())
×
75
        }
76
        for idx := 1; idx <= 10; idx++ {
×
77
                pw, err := g.Generate()
×
78
                if err != nil {
×
79
                        panic(err.Error())
×
80
                }
81
                fmt.Printf("Password #%3d: %#v\n", idx, pw)
×
82
        }
83
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc