mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-12-02 14:46:31 +00:00
c28f7cb29f
Initial part of #435
50 lines
1.2 KiB
Go
50 lines
1.2 KiB
Go
package frequency
|
|
|
|
import (
|
|
"encoding/json"
|
|
"log"
|
|
|
|
"github.com/nbutton23/zxcvbn-go/data"
|
|
)
|
|
|
|
// List holds a frequency list
|
|
type List struct {
|
|
Name string
|
|
List []string
|
|
}
|
|
|
|
// Lists holds all the frequency list in a map
|
|
var Lists = make(map[string]List)
|
|
|
|
func init() {
|
|
maleFilePath := getAsset("data/MaleNames.json")
|
|
femaleFilePath := getAsset("data/FemaleNames.json")
|
|
surnameFilePath := getAsset("data/Surnames.json")
|
|
englishFilePath := getAsset("data/English.json")
|
|
passwordsFilePath := getAsset("data/Passwords.json")
|
|
|
|
Lists["MaleNames"] = getStringListFromAsset(maleFilePath, "MaleNames")
|
|
Lists["FemaleNames"] = getStringListFromAsset(femaleFilePath, "FemaleNames")
|
|
Lists["Surname"] = getStringListFromAsset(surnameFilePath, "Surname")
|
|
Lists["English"] = getStringListFromAsset(englishFilePath, "English")
|
|
Lists["Passwords"] = getStringListFromAsset(passwordsFilePath, "Passwords")
|
|
|
|
}
|
|
func getAsset(name string) []byte {
|
|
data, err := data.Asset(name)
|
|
if err != nil {
|
|
panic("Error getting asset " + name)
|
|
}
|
|
|
|
return data
|
|
}
|
|
func getStringListFromAsset(data []byte, name string) List {
|
|
|
|
var tempList List
|
|
err := json.Unmarshal(data, &tempList)
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
tempList.Name = name
|
|
return tempList
|
|
}
|