mirror of
https://github.com/wneessen/apg-go.git
synced 2024-12-22 11:10:39 +01:00
Refactor error formatting and update Go version in linter config
Reformatted error messages to use %w for improved error handling in "random.go", and updated the used Go version in the ".golangci.toml" file. Also, removed some unnecessary lines in "random_test.go" and improved the layout of an array in "koremutake.go".
This commit is contained in:
parent
8fef635664
commit
239501e83b
4 changed files with 8 additions and 8 deletions
|
@ -3,14 +3,13 @@
|
|||
# SPDX-License-Identifier: CC0-1.0
|
||||
|
||||
[run]
|
||||
go = "1.20"
|
||||
go = "1.22"
|
||||
tests = true
|
||||
skip-dirs = ["ui/"]
|
||||
|
||||
[linters]
|
||||
enable = ["stylecheck", "whitespace", "containedctx", "contextcheck", "decorder",
|
||||
"errname", "errorlint", "gofmt", "gofumpt", "goimports"]
|
||||
|
||||
[linters-settings.goimports]
|
||||
local-prefixes = "git.cgn.cleverbridge.com/infosec/vulnmon"
|
||||
local-prefixes = "src.neessen.cloud/wneessen/apg-go"
|
||||
|
||||
|
|
|
@ -6,7 +6,8 @@ package apg
|
|||
|
||||
// KoremutakeSyllables is a slightly modified Koremutake syllables list based on
|
||||
// the mechanism described on https://shorl.com/koremutake.php
|
||||
var KoremutakeSyllables = []string{"ba", "be", "bi", "bo", "bu", "by", "da", "de", "di",
|
||||
var KoremutakeSyllables = []string{
|
||||
"ba", "be", "bi", "bo", "bu", "by", "da", "de", "di",
|
||||
"do", "du", "dy", "fe", "fi", "fo", "fu", "fy", "ga", "ge", "gi", "go", "gu",
|
||||
"gy", "ha", "he", "hi", "ho", "hu", "hy", "ja", "je", "ji", "jo", "ju", "jy",
|
||||
"ka", "ke", "ko", "ku", "ky", "la", "le", "li", "lo", "lu", "ly", "ma",
|
||||
|
@ -23,4 +24,5 @@ var KoremutakeSyllables = []string{"ba", "be", "bi", "bo", "bu", "by", "da", "de
|
|||
"col", "ful", "get", "low", "son", "tle", "day", "pen", "pre", "ten",
|
||||
"tor", "ver", "ber", "can", "ple", "fer", "gen", "den", "mag", "sub", "sur",
|
||||
"men", "min", "out", "tal", "but", "cit", "cle", "cov", "dif", "ern",
|
||||
"eve", "hap", "ket", "nal", "sup", "ted", "tem", "tin", "tro", "tro"}
|
||||
"eve", "hap", "ket", "nal", "sup", "ted", "tem", "tin", "tro", "tro",
|
||||
}
|
||||
|
|
|
@ -318,7 +318,7 @@ func (g *Generator) generatePronounceable() (string, error) {
|
|||
for int64(len(password)) < length {
|
||||
randNum, err := g.RandNum(int64(characterSetLength))
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("failed to generate a random number for Koremutake syllable generation: %s",
|
||||
return "", fmt.Errorf("failed to generate a random number for Koremutake syllable generation: %w",
|
||||
err)
|
||||
}
|
||||
nextSyllable := characterSet[randNum]
|
||||
|
@ -326,7 +326,7 @@ func (g *Generator) generatePronounceable() (string, error) {
|
|||
syllableLength := len(nextSyllable)
|
||||
characterPosition, err := g.RandNum(int64(syllableLength))
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("failed to generate a random number for Koremutake syllable generation: %s",
|
||||
return "", fmt.Errorf("failed to generate a random number for Koremutake syllable generation: %w",
|
||||
err)
|
||||
}
|
||||
randomChar := string(nextSyllable[characterPosition])
|
||||
|
|
|
@ -322,7 +322,6 @@ func TestGeneratePronounceable(t *testing.T) {
|
|||
if foundSylables < 100 {
|
||||
t.Errorf("generatePronounceable() failed, expected at least 1 sylable, got none")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func TestCheckMinimumRequirements(t *testing.T) {
|
||||
|
|
Loading…
Reference in a new issue