Initial checkin

This commit is contained in:
Malcolm Roberts 2024-02-15 18:55:37 +00:00
commit ea8290a2a2
6 changed files with 2081 additions and 0 deletions

View File

@ -0,0 +1,13 @@
{
"image": "mcr.microsoft.com/devcontainers/go",
"customizations": {
"vscode": {
"extensions": [
"golang.go"
]
}
},
"mounts": [
"source=${localEnv:HOME}${localEnv:USERPROFILE}/.ssh,target=/home/vscode/.ssh,type=bind,consistency=cache",
]
}

22
.gitignore vendored Normal file
View File

@ -0,0 +1,22 @@
# If you prefer the allow list template instead of the deny list, see community template:
# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore
#
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib
# Test binary, built with `go test -c`
*.test
# Output of the go coverage tool, specifically when used with LiteIDE
*.out
# Dependency directories (remove the comment below to include it)
# vendor/
# Go workspace file
go.work
usergen

3
go.mod Normal file
View File

@ -0,0 +1,3 @@
module github.com/mickeyr/usergen
go 1.22.0

43
main.go Normal file
View File

@ -0,0 +1,43 @@
package main
import (
"crypto/rand"
"embed"
"flag"
"fmt"
"math/big"
"strings"
)
var (
//go:embed resources
res embed.FS
// embed the resources/nouns.txt & resources/verbs.txt files as arrays of strings split by newlines
nouns []string
verbs []string
)
var count int
func init() {
nounsContents, _ := res.ReadFile("resources/nouns.txt")
nouns = strings.Split(string(nounsContents), "\n")
verbsContents, _ := res.ReadFile("resources/verbs.txt")
verbs = strings.Split(string(verbsContents), "\n")
flag.IntVar(&count, "count", 10, "number of nouns and verbs to print")
}
func main() {
flag.Parse()
fmt.Println("count is ", count)
// Print the first 10 nouns and verbs
for i := 0; i < count; i++ {
randomNounIdx, _ := rand.Int(rand.Reader, big.NewInt(int64(len((nouns)))))
randomVerbIdx, _ := rand.Int(rand.Reader, big.NewInt(int64(len((verbs)))))
fmt.Printf("%s-%s\n", nouns[randomNounIdx.Int64()], verbs[randomVerbIdx.Int64()])
}
}

1000
resources/nouns.txt Normal file

File diff suppressed because it is too large Load Diff

1000
resources/verbs.txt Normal file

File diff suppressed because it is too large Load Diff